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
842 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 61

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 61

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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 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.:

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now