From f62a47dd2c4b9f30fd1a302f93ca94fdd8653203 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 15 Feb 2014 17:54:20 +0100 Subject: [PATCH] [FIX] Abort cron on locking failure Fixes #1762 --- cronjobs/run-crons.sh | 5 ++++- cronjobs/run-maintenance.sh | 5 ++++- cronjobs/run-payout.sh | 5 ++++- cronjobs/run-statistics.sh | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cronjobs/run-crons.sh b/cronjobs/run-crons.sh index 55dee0bd..66c59c1f 100755 --- a/cronjobs/run-crons.sh +++ b/cronjobs/run-crons.sh @@ -115,7 +115,10 @@ if [[ -e $PIDFILE ]]; then fi # Write our PID file -echo $PID > $PIDFILE +echo $PID 2>/dev/null 1> $PIDFILE || { + echo 'Failed to create PID file, aborting'; + exit 1 +} for cron in $CRONS; do [[ $VERBOSE == 1 ]] && echo "Running $cron, check logfile for details" diff --git a/cronjobs/run-maintenance.sh b/cronjobs/run-maintenance.sh index cd3ae296..1161f4cd 100755 --- a/cronjobs/run-maintenance.sh +++ b/cronjobs/run-maintenance.sh @@ -115,7 +115,10 @@ if [[ -e $PIDFILE ]]; then fi # Write our PID file -echo $PID > $PIDFILE +echo $PID 2>/dev/null 1> $PIDFILE || { + echo 'Failed to create PID file, aborting'; + exit 1 +} for cron in $CRONS; do [[ $VERBOSE == 1 ]] && echo "Running $cron, check logfile for details" diff --git a/cronjobs/run-payout.sh b/cronjobs/run-payout.sh index d14a56bd..5534122f 100755 --- a/cronjobs/run-payout.sh +++ b/cronjobs/run-payout.sh @@ -115,7 +115,10 @@ if [[ -e $PIDFILE ]]; then fi # Write our PID file -echo $PID > $PIDFILE +echo $PID 2>/dev/null 1> $PIDFILE || { + echo 'Failed to create PID file, aborting'; + exit 1 +} for cron in $CRONS; do [[ $VERBOSE == 1 ]] && echo "Running $cron, check logfile for details" diff --git a/cronjobs/run-statistics.sh b/cronjobs/run-statistics.sh index d41ac2a1..9aa29737 100755 --- a/cronjobs/run-statistics.sh +++ b/cronjobs/run-statistics.sh @@ -115,7 +115,10 @@ if [[ -e $PIDFILE ]]; then fi # Write our PID file -echo $PID > $PIDFILE +echo $PID 2>/dev/null 1> $PIDFILE || { + echo 'Failed to create PID file, aborting'; + exit 1 +} for cron in $CRONS; do [[ $VERBOSE == 1 ]] && echo "Running $cron, check logfile for details"