patschi

PlexWatch 30 sec job

Feb 24th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  1. #!/bin/bash
  2. SLEEPTIME="30"
  3. PIDFILE="/tmp/plexWatchJob.pid"
  4.  
  5. if [ -f "$PIDFILE"  ]; then
  6.         PID=$(cat $PIDFILE)
  7.         if ps -p $PID > /dev/null; then
  8.                 echo "Job already running. Aborting."
  9.                 exit 1
  10.         else
  11.                 echo "PID file existing, but Job not running. Starting..."
  12.         fi
  13. fi
  14.  
  15. echo "Starting job..."
  16. echo $BASHPID > /tmp/plexWatchJob.pid
  17.  
  18. while [ -f "$PIDFILE"  ]; do
  19.         sleep $SLEEPTIME
  20.         /opt/plexWatch/plexWatch.pl
  21. done
  22.  
  23. echo "Job ended."
Add Comment
Please, Sign In to add comment