How to sequence cron jobs?


 
Thread Tools Search this Thread
Operating Systems Solaris How to sequence cron jobs?
# 1  
Old 12-04-2009
How to sequence cron jobs?

Hello all,
I have 3 scripts that I have to run using cron tab and 2 scripts are dependent on the first script.

How do I schedule cron jobs such that 2nd job follows first and 3rd follows 2nd.

For example, I have 3 jobs - job1, job2 and job3, that have to run every 3 hours.

I want the jobs to run in the following order.
If job1 is successful, run job2
If job2 is successful, run job3.

Will this work?
Code:
0 0-23/3 * * * job1 && job2 && job3

# 2  
Old 12-04-2009
A simpler solution is to create a wrapper script to check the return codes of each process. Run the wrapper script once every three hours.

The example you gave will work - but be sure to enter the full file specification:
/path/to/job1 && /another/path/job2
# 3  
Old 12-04-2009
Quote:
Originally Posted by grajp002

Will this work?
Code:
0 0-23/3 * * * job1 && job2 && job3

It won't because the 0-23/3 syntax is incorrect. The && stuff is right though.
# 4  
Old 12-04-2009
@jlliagre

Then how do we schedule to run the job every 3 hours everyday?

Please let me know!
# 5  
Old 12-04-2009
This should work;
Code:
0 0,3,6,9,12,15,18,21 * * *

# 6  
Old 12-04-2009
Quote:
Originally Posted by jlliagre
It won't because the 0-23/3 syntax is incorrect. The && stuff is right though.
That depends. The Vixie Cron (written by Paul Vixie) on Linux systems does support an extension that uses the slash to indicate an interval.
# 7  
Old 12-04-2009
You are right, while that syntax is incorrect in that Solaris forum context, I should have written it is unsupported.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron Jobs

How to see which cron jobs are not running? (2 Replies)
Discussion started by: rahul.raj1989
2 Replies

2. Solaris

Cron jobs and at jobs

There are two jobs in Solaris , Cron and at jobs.. I know how to disable or enable cron jobs. How can I enable at jobs and disable it. Kindly help. Rj (2 Replies)
Discussion started by: jegaraman
2 Replies

3. Shell Programming and Scripting

cron jobs

Hi, please help on this am trying to exec the below mentioned cron jobs but its getting failed fro the past two days ###but when am trying to execte the cron by the times 23,29 18 * * * /export/home/inrvgo/thelak/China.sh its getting exec properly please help on this #... (8 Replies)
Discussion started by: thelakbe
8 Replies

4. Solaris

cron jobs

how to Put a cron entry which should be same script triggered on every Saturday and 1st of every month at 01.00 GMT. 0 2 1 * 6 --( At 2.00 GMT every sat & on 1st of every month) the above syntax is correct? Thanks (1 Reply)
Discussion started by: kurva
1 Replies

5. UNIX for Advanced & Expert Users

cron jobs...

I need to start a job every friday night at 8:00 P.M , it runs all the day on Sat and Sun....can somebody tell me how to do this...I understand crontab...but haven't used it.........can u write some steps.....how to create a file and call.....I honestly dont know? Plz help.Thanks (2 Replies)
Discussion started by: RubinPat
2 Replies

6. Linux

cron jobs

I created a php script. I'd like to have it run as a cron job every day at 10:30am. So i added 30 10 * * * /script.php to the cron file Is it possible to run the script on the command line to test it out ? (1 Reply)
Discussion started by: dannyd
1 Replies

7. HP-UX

Cron jobs

i am new for cronjobs can someone please tell me what logic is behind these RED Numbers and stars below? --> crontab -l 00 1 * * * /home/scripts/TarprodContent > /tmp/MprodBkup.log 2>&1 00 1 * * * /home/scripts/TarTprodContent > /tmp/TprodBkup.log 2>&1 00 1 * * *... (5 Replies)
Discussion started by: ajadaun
5 Replies

8. Solaris

Cron Jobs

whats up, Have some questions about cron jobs, I am fairly new to the unix os. My cronjob sends all output to my mail, does anyone know how to redirect output to come out on the screen??? Thanks...... (6 Replies)
Discussion started by: lewisoco
6 Replies

9. UNIX for Dummies Questions & Answers

Cron Jobs

Where can someone find info on Cron Jobs? Very new to UNIX and the PC I inherited looks to have several of them. Looks like they are some kind of background program that runs automatically at specified times. Would like to delete some of them and know more about them. (6 Replies)
Discussion started by: dereckbc
6 Replies

10. UNIX for Dummies Questions & Answers

cron jobs

I was wondering if itīs possible to cron job not to run on a certian day and time. Iīve got a job that runs everyday at 08:00 but would like it not to run on the 20:th between 08:00 and 10:00 Anyone know if this is possible, and if. How do i do it? regards... dOzY (3 Replies)
Discussion started by: dozy
3 Replies
Login or Register to Ask a Question