how to stop a task in crontab to run if the previous instance has been still running in AIX?

Hello,

In AIX, is there a way to stop a a scheduled task in crontab to run if the just previous instance has been still running?

Thanks
AnkCBSAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
maysaraConnect With a Mentor Commented:
you could always write a script that checks for a lock file, the first script writes the lock file and deletes it when done, the second file doesnt start if the lock fil exists, just a simple and could be empty file, and  a small check if its there or not.
0
 
maysaraConnect With a Mentor Commented:
maybe you could start the second job after the first is finished, using && , for example:

command1 && command2 , ie:

sleep 5 && ls
0
 
AnkCBSAuthor Commented:
Hello Maysara,

Your second answer, which is a solution at application level, is what I would apply if I couldn't find any solution in crontab level. I thought that there is way using crontab as in "MS scheduled task".

Anyway, thanx for the answer
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
gheistConnect With a Mentor Commented:
You can write a script that checks if previous process is still running by
kill -0 `cat /tmp/app.pid` || (startapp & echo $! > /tmp/app.pid)

more on ksh:
http://b62.tripod.com/doc/docksh.htm
(some things are different in bash, so install pdksh in linux should you ever need your scripts running there)
0
 
omarfaridConnect With a Mentor Commented:
crontab does not check if the previous job is still running or not before starting a new one. You need to do it at your script level to either

- check if the process is still running (using ps -ef | grep -v grep | grep processname)
- or check for the existence of a file which is created by previous run and should be removed after finishing previous run)
0
 
gheistCommented:
I did perfect process check btw
0
 
AnkCBSAuthor Commented:
Hello again,

I will code it in the application level. Thank you all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.