?
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
?
857 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

719 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