Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-04-05
7
Medium Priority
?
858 Views
Last Modified: 2013-11-17
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
0
Comment
Question by:AnkCBS
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 4

Assisted Solution

by:maysara
maysara earned 360 total points
ID: 24072103
maybe you could start the second job after the first is finished, using && , for example:

command1 && command2 , ie:

sleep 5 && ls
0
 
LVL 4

Accepted Solution

by:
maysara earned 360 total points
ID: 24072113
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
 

Author Comment

by:AnkCBS
ID: 24077106
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 62

Assisted Solution

by:gheist
gheist earned 90 total points
ID: 24085210
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
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 300 total points
ID: 24094058
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
 
LVL 62

Expert Comment

by:gheist
ID: 24094710
I did perfect process check btw
0
 

Author Comment

by:AnkCBS
ID: 24097399
Hello again,

I will code it in the application level. Thank you all.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question