LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab help (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-help-631828/)

i.you 03-31-2008 02:40 AM

crontab help
 
Hello guys

I'd like to know if there's any way to run one first and the other (about 1 min.) later as two tasks are set as same time in cron table.
is it possible?

Please let me know the site or docomentations about it.

Thanks.

colucix 03-31-2008 03:07 AM

If you cannot change the crontab, maybe you can add a
Code:

sleep 60
at the beginning of the second task. But I suspect it is not so simple, isn't it?

salasi 03-31-2008 04:39 AM

Quote:

Originally Posted by i.you (Post 3105614)
Hello guys

I'd like to know if there's any way to run one first and the other (about 1 min.) later as two tasks are set as same time in cron table.
is it possible?

Maybe I've misunderstood your question, but can you simply write a script that runs one task first and then runs the second task, maybe with a delay between the two?

i.you 03-31-2008 08:20 PM

Thanks guys,

No, it isn't so simple.
Each task can be scheduled to cron table by user programs.
so they can be set as the same time or not.
also cannot know the order.

I just want to know if it is possible like this :

Quote:

# IN CRONTAB

if the set time of program_A and program_B is the same
then
run program_A
sleep 1 min.
run program_B
fi
Thanks.

billymayday 03-31-2008 08:33 PM

Why not have the first touch a file and delete it once complete, and the second not start while the file exists?

Edit - the second probably needs to leave it's own file - you can't guarantee which will start first necessarily I suspect.

chrism01 03-31-2008 08:38 PM

Short answer; no.
crontabs are simple flat files, read by the crond daemon. It's not a programming lang/env.
Know that cron can run multiple jobs at the same time. The qn is whether it matters ie does prog 2 rely on output from prog1.?
If yes, you need to fix that at the prog level.

prad77 03-31-2008 09:23 PM

guess billymayday's solution is quite practical and simple. we run install scripts for clusters that way. the second script will wait for the first script by checking for a temp file created by first script. this way handshakes and concurrent installtions are done successfully. Ofcourse you have to check for indefinite waiting with a count down loop.

Gentoo


All times are GMT -5. The time now is 08:10 PM.