LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-31-2008, 03:40 AM   #1
i.you
Member
 
Registered: Oct 2006
Posts: 46

Rep: Reputation: 15
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.
 
Old 03-31-2008, 04:07 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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?
 
Old 03-31-2008, 05:39 AM   #3
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,053

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
Quote:
Originally Posted by i.you View Post
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?
 
Old 03-31-2008, 09:20 PM   #4
i.you
Member
 
Registered: Oct 2006
Posts: 46

Original Poster
Rep: Reputation: 15
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.
 
Old 03-31-2008, 09:33 PM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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.

Last edited by billymayday; 03-31-2008 at 09:51 PM.
 
Old 03-31-2008, 09:38 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
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.
 
Old 03-31-2008, 10:23 PM   #7
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
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

Last edited by prad77; 04-17-2008 at 04:32 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab kwtan Linux - Newbie 2 11-27-2005 10:43 PM
crontab x2??? killahsmurf Slackware 2 05-24-2005 11:53 PM
crontab -e hoover93 Linux - Newbie 2 08-06-2004 05:05 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 01:35 PM
crontab help usman Linux - General 7 08-06-2003 04:37 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration