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
846 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 120 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 120 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 62

Assisted Solution

by:gheist
gheist earned 30 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 100 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSH commands for Nas4free 21 426
Unix / Linux grid computing 5 157
text in table need to be center of the box 4 79
Bash Script to Analyze Oracle Schemas 11 107
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

803 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