Skip to content

Commit 5fe2199

Browse files
crontab: refactored cron runner
1 parent 5822d6a commit 5fe2199

10 files changed

Lines changed: 19 additions & 7 deletions

File tree

.bin/cron-run-dir.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CRON_RUN_DIR="$1"
2+
3+
for script_file in $CRON_RUN_DIR/*.sh;
4+
do
5+
if test -f "$script_file"; then
6+
CRON_SCRIPT_LOG_FILE="/tmp/cron/$CRON_RUN_DIR/$(basename $script_file)"
7+
mkdir -p "$(dirname $CRON_SCRIPT_LOG_FILE)"
8+
9+
sh -x "$script_file" > "$CRON_SCRIPT_LOG_FILE" 2>&1
10+
echo "EXIT CODE: $?" >> "$CRON_SCRIPT_LOG_FILE"
11+
fi
12+
done

.cron/weekday-afternoon/exemple.sh

Whitespace-only changes.

.cron/weekday-any/exemple.sh

Whitespace-only changes.

.crontab

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#=====================================================================#
2020
# Min | Hour | Mday | Month | Wday | Command #
2121
#=====================================================================#
22-
0 3 * * * test -x $HOME/.cron/daily-night.sh && $HOME/.cron/daily-night.sh > /dev/null 2>&1
23-
*/5 * * * * test -x $HOME/.cron/5min-any.sh && $HOME/.cron/5min-any.sh > /dev/null 2>&1
24-
0 * * * * test -x $HOME/.cron/hourly-any.sh && $HOME/.cron/hourly-any.sh > /dev/null 2>&1
25-
20 17 * * 1-5 test -x $HOME/.cron/weekday-afternoon.sh && $HOME/.cron/weekday-afternoon.sh > /dev/null 2>&1
26-
0 17 * * 0 test -x $HOME/.cron/daily-afternoon.sh && $HOME/.cron/daily-afternoon.sh > /dev/null 2>&1
27-
0 7 * * 0 test -x $HOME/.cron/daily-morning.sh && $HOME/.cron/daily-morning.sh > /dev/null 2>&1
28-
0 0 * * 5 test -x $HOME/.cron/weekend-any.sh && $HOME/.cron/weekend-any.sh > /dev/null 2>&1
22+
0 3 * * * sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/daily-night" > /dev/null 2>&1
23+
*/5 * * * * sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/5min-any" > /dev/null 2>&1
24+
0 * * * * sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/hourly-any" > /dev/null 2>&1
25+
20 17 * * 1-5 sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/weekday-afternoon" > /dev/null 2>&1
26+
0 17 * * 0 sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/daily-afternoon" > /dev/null 2>&1
27+
0 7 * * 0 sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/daily-morning" > /dev/null 2>&1
28+
0 0 * * 5 sh $HOME/.bin/cron-run-dir.sh "$HOME/.cron/weekend-any" > /dev/null 2>&1
2929
#=====================================================================#

0 commit comments

Comments
 (0)