Link to home
Start Free TrialLog in
Avatar of EvanstonEddie
EvanstonEddie

asked on

Simultaneous Runs

I am sort of new to UNIX and don't know much of the commands, there I have this question to ask of you guys.

I have a unix script that is on a schedule to run every friday at 5pm, and to also run on last day of month at 5pm.  There will be cases when the two criterias above are true, therefore causing the same job to run simultaneously.  Are there any UNIX statements that would avoid this situation from occuring?

Thanks much for your help!
Avatar of bira
bira

Place a test in your script as follow:

a=`ps -ef |grep YOURSCRIPT`
if [ $? -eq 0 ] ; then
echo "this is running now"
exit
fi

   So the script will never run if it find another instance
 running.
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
in bira's script you should change the first line for
a=`ps -ef |grep YOURSCRIPT|grep -v grep`
otherwise the script will never run.
Hey Santunes

  I agree

    Regards
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial