Re: where to set a if condition for a crontab job to execute
What you post would work, assuming nothing else is going to call job1.sh. But unless execute_task1.sh is going to more than just job1.sh then put the locking stuff in job1.sh and call job1.sh from crontab.
Originally Posted by oj43085
It might help if you made your self a simple script to see how the locking works. E.g.
Run that, then try running another instance of it.
exec 9>/tmp/$(basename $0)_lock
if ! flock -n 9 ; then
echo "another instance is running";
If you find this post helpful and are logged into the web interface, please show your appreciation and click on the star below... thanks!