irpg_wrapper.sh 510 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. ## A script to wrap idlerpg for cron
  3. # Run in crontab with:
  4. # fyi, the irpg needs to be called from it's local dir, so link the wrapper there
  5. # */30 * * * * /home/demure/irpg/irpg_wrapper.sh
  6. IDLE_DIR="/irpg/"
  7. IDLE_CMD="perl ${IDLE_DIR}irpg_bot.pl"
  8. IDLE_PID="$(pgrep -f "${IDLE_CMD}" | wc -l)"
  9. cd $IDLE_DIR
  10. if [ "${IDLE_PID}" -eq "0" ]; then
  11. ${IDLE_CMD} 2>&1 1>/dev/null
  12. else
  13. if [ "${IDLE_PID}" -gt "1" ]; then
  14. pkill -f "${IDLE_CMD}"
  15. ${IDLE_CMD} 2>&1 1>/dev/null
  16. fi
  17. fi