Bash if and or conditionals -


i have perl script runs in cron , if script fails run leaves behind lock file prevent script run again.

i'm trying run bash script checks if process running , checks see if lock file left behind

if processes running , lock file exists exit 0;

if process not running , lock file exists rm lockfile. exit 0;

if process not exist , lock file 'not present' exit 0;

i've been checking if process exists running ps ax |grep -v grep |grep process.pl

i'm looking conditionals in bash should running here.

thanks

the process.pl should write process id lockfile, wihch common pattern. can write following code:

if [ -f "$lockfile" ];   pid=$(cat "$lockfile")   if kill -0 "$pid";     : "running normally"   else     : "terminated somehow"     rm -f "$lockfile"   fi fi 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -