Advertisement
cmptrwz

run_cron

May 28th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Intended usage: add into cron job commands
  4. # Ex: . ~/.bashrc && $EG_BIN_DIR/run_cron && $EG_BIN_DIR/blah
  5. # This should hopefully stop "SERVICES AREN'T RUNNING!" error messages from being sent
  6.  
  7. if [ -f "/openils/conf/stop_cron" ]; then
  8.     # Intentionally stop cron jobs
  9.     exit 1
  10. fi
  11.  
  12. if [ "$(ls -1 /openils/var/run/opensrf/*.pid 2>/dev/null | wc -l)" -lt 20 ]; then
  13.     # Not enough services apparently running
  14.     exit 2
  15. fi
  16.  
  17. for PID in $(cat /openils/var/run/opensrf/*.pid); do
  18.     # Check all service PID files
  19.     if ! ps -p $PID > /dev/null 2>&1; then
  20.         # If a service's PID isn't active, bail
  21.         exit 3
  22.     fi
  23. done
  24.  
  25. # Assume success if we reach this point
  26. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement