After the Massachusetts Library Network Cooperative training session I
took a look at the example crontab file, and thought about the
"Restarting services" part of the session.
In particular, the "Disable any cron jobs ('crontab -u opensrf -e' -
comment out the lines)" part.
Attached is a small patch to make that a lot easier and safer to
accomplish, as well as giving a way for nagios or similar to easily
check if they are disabled. Incidentally inspired from the "wait until
the system has been up for five minutes" variant crontab Don showed us
from the test system.
Thomas Berezansky
Merrimack Valley Library Consortium
Index: Open-ILS/examples/crontab.example
===================================================================
--- Open-ILS/examples/crontab.example (revision 16388)
+++ Open-ILS/examples/crontab.example (working copy)
@@ -18,6 +18,11 @@
#
# Except where indicated, these processes only need to run
# on 1 Evergreen server/brick.
+#
+# To disable the cron jobs on a temporary basis you can, assuming
+# a default install directory:
+# touch /openils/var/lock/nocron.lock
+# Remove that file to set them to run again.
# ENVIRONMENT:
@@ -31,45 +36,45 @@
# m h dom mon dow command
# Run the hold targeter
-* */4 * * * . ~/.bashrc && $EG_BIN_DIR/hold_targeter.pl $SRF_CORE
+* */4 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/hold_targeter.pl $SRF_CORE
# Run the hold thawer
-5 0 * * * . ~/.bashrc && $EG_BIN_DIR/thaw_expired_frozen_holds.srfsh
+5 0 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/thaw_expired_frozen_holds.srfsh
# Generate fines
-30 0 * * * . ~/.bashrc && $EG_BIN_DIR/fine_generator.pl $SRF_CORE
+30 0 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/fine_generator.pl $SRF_CORE
# Run the reshelving completer
-2 0 * * * . ~/.bashrc && $EG_BIN_DIR/reshelving_complete.srfsh
+2 0 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/reshelving_complete.srfsh
# create the list of blocked patrons for offline use
# Note: The resulting list.txt file needs to be copied to all Apache servers
-30 6 * * * . ~/.bashrc && $EG_BIN_DIR/offline-blocked-list.pl $SRF_CORE > $OPENILS/var/web/standalone/list.txt
+30 6 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/offline-blocked-list.pl $SRF_CORE > $OPENILS/var/web/standalone/list.txt
# Restart SIP nightly to free up any orphaned processes.
# Note: Run on all SIP servers
-# 5 2 * * * . ~/.bashrc && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a stop_sip
-# 8 2 * * * . ~/.bashrc && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a start_sip
+# 5 2 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a stop_sip
+# 8 2 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && oils_ctl.sh -d $OPENILS/var/pid -s $OPENILS/conf/oils_sip.xml -a start_sip
# Action/Trigger entries ----
# Runs all pending A/T events every half hour
-0 */2 * * * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --run-pending
+0 */2 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --run-pending
# Passive A/T event generation.
# Note: the --granularity flag is not supported in 1.6
# Note: passive event defs with no granularity will be processed regardless of any granularity flags
# Note: push these back to 3am so they will run after the fine generator and spread out the start minute to reduce dogpiling
-0 * * * * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity hourly
-5 3 * * * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity daily
-10 3 * * 1-5 . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekdays
-15 3 * * 0 . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekly
-20 3 1 * * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity monthly
-25 3 1 1 * . ~/.bashrc && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity yearly
+0 * * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity hourly
+5 3 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity daily
+10 3 * * 1-5 . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekdays
+15 3 * * 0 . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity weekly
+20 3 1 * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity monthly
+25 3 1 1 * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && $EG_BIN_DIR/action_trigger_runner.pl --osrf-config $SRF_CORE --process-hooks --granularity yearly
# Legacy overdue/predue notice generator. Change to suit.
#XML_FILE_PREFIX = /openils/var/data/overdue/overdue
-#0 3 * * * . ~/.bashrc && cd $EG_BIN_DIR && ./generate_circ_notices.pl --osrf_config $SRF_CORE --notice-types overdue,predue --generate-global-templates --send-email > $XML_FILE_PREFIX.$(date +"\%F").xml
+#0 3 * * * . ~/.bashrc && [ ! -f $OPENILS/var/lock/nocron.lock ] && cd $EG_BIN_DIR && ./generate_circ_notices.pl --osrf_config $SRF_CORE --notice-types overdue,predue --generate-global-templates --send-email > $XML_FILE_PREFIX.$(date +"\%F").xml
# TODO: add other entries