From 05518d7034015c9cf7e29ba94f106836f29c9a98 Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Mon, 31 Jul 2023 17:08:55 +0000 Subject: [PATCH] simple script to make an executable script based on crontab. --- all-crons.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 all-crons.sh diff --git a/all-crons.sh b/all-crons.sh new file mode 100755 index 0000000..0e819fe --- /dev/null +++ b/all-crons.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# this only works if your crontab uses three spaces for each section, +# like the following spacing example: +#m h dom mon dow command + +# quickly generate a script file which will run each crontab task +# optionally takes filename to use, otherwise defaults 'crontasks.sh' +FILENAME="$1" + +if [ -z "$FILENAME" ]; then + FILENAME='crontasks.sh' +fi + +echo "#!/bin/bash\n" > "$FILENAME" + +# list crontab, remove comments and empty lines, +# expect cron time formatting to be the first 20 characters, +# so drop the 21st character onward to standard out. +crontab -l | grep -Ev '^(#|$)' | cut -c 21- >> "$FILENAME" + +chmod +x "$FILENAME" +