Skip to content

Instantly share code, notes, and snippets.

View distributedlife's full-sized avatar

Ryan Boucher distributedlife

View GitHub Profile
@distributedlife
distributedlife / runjob_if_not_running.sh
Created November 2, 2011 00:40
Run a script if a process is not running
#!/bin/bash -e
#$1 = the regex to identify the job; should use the pattern "[m]y job"
#$2 = the script to run
REGEX=$1
SCRIPT=$2
#try and get the PID
PSID=`ps -ef | grep "$REGEX" -m 01 | awk '{print $2}'`