Operating System - HP-UX
1748151 Members
3619 Online
108758 Solutions
New Discussion

scheduling the cron jobs with the use of operands

 
SOLVED
Go to solution
simma100
Occasional Contributor

scheduling the cron jobs with the use of operands

Need to schedule the cronjob, like i am having 2 scipts on my crontab. if 1st job completed successfully then the 2nd job need to start. Is there any operands can we use for that. Please let me know if any options are there.

 

Thanks!

Simhan

14 REPLIES 14
Dennis Handly
Acclaimed Contributor

Re: scheduling the cron jobs with the use of operands

You only have the first script in your crontab.  If successful, the first script can start the next.

 

Or have three scripts.  The new one starts the first and if successful, starts the next.

Stephan_
Regular Advisor

Re: scheduling the cron jobs with the use of operands

Hi,

create a script f.e. cronscript.sh

 

/path/to/first/script && /path/to/second/script

 

 

add the following line to your crontab (Change times)

 

*   *    *    *    *    /path/to/cronscript.sh

 

Or you can enter that line directly into the crontab, using && will only execute the second command if the return code of the first one was zero.

 

hth

Stephan

 

How to assign points on this new forums --> Kudos - what, where, how, and why!
How to find the right forum --> New forum location by ITRC tree

"we wouldn't call it code, if we could read it ..."
simma100
Occasional Contributor

Re: scheduling the cron jobs with the use of operands

Hello Stephen,

 

If i  want to scedule the ignite backup once the tape drive is rewinded

 

0 5 11 6 /usr/sbin/mt -t /dev/rmt/omn rewind && * * * * /usr/sbin/make_tape_recovery -A -i -v inc_entire=/dev/vg00 /dv/rmt/0mn

 

Is that right.. Please correct me if i am wrong.

Dennis Handly
Acclaimed Contributor

Re: scheduling the cron jobs with the use of operands

>If I  want to schedule the ignite backup once the tape drive is rewound

 

In this case you shouldn't have separate commands in crontab.  Instead create one script that does the rewind, waits, then does the ignite.

Stephan_
Regular Advisor

Re: scheduling the cron jobs with the use of operands


@simma100 wrote:

Hello Stephen,

 

If I  want to schedule the ignite backup once the tape drive is rewinded

 

0 5 11 6 /usr/sbin/mt -t /dev/rmt/omn rewind && * * * * /usr/sbin/make_tape_recovery -A -I -v inc_entire=/dev/vg00 /dv/rmt/0mn

 

Is that right.. Please correct me if I am wrong.


Hi again,
0 5 11 6 /usr/sbin/mt -t /dev/rmt/omn rewind && /usr/sbin/make_tape_recovery -A -I -v 

 

This should work, or as mentioned before create separate scripts for it.

 

Best,

Stephan

How to assign points on this new forums --> Kudos - what, where, how, and why!
How to find the right forum --> New forum location by ITRC tree

"we wouldn't call it code, if we could read it ..."
simma100
Occasional Contributor

Re: scheduling the cron jobs with the use of operands

so stephen, don't want to mention the tape device file at the last in the ignite command ?
Stephan_
Regular Advisor
Solution

Re: scheduling the cron jobs with the use of operands

Ups,

sorry of course you should add it - seems i did not copy all, to finalize

 

0 5 11 6 /usr/sbin/mt -t /dev/rmt/omn rewind && /usr/sbin/make_tape_recovery -A -I -v inc_entire=/dev/vg00 /dv/rmt/0mn

 

Best,

Stephan

How to assign points on this new forums --> Kudos - what, where, how, and why!
How to find the right forum --> New forum location by ITRC tree

"we wouldn't call it code, if we could read it ..."
simma100
Occasional Contributor

Re: scheduling the cron jobs with the use of operands

Thanks stephen.. i got that one.. again thanks a ton... :)
Bill Hassell
Honored Contributor

Re: scheduling the cron jobs with the use of operands

Actually, there are a lot of problems with just a rewind and trying to run the backup with a one-liner. Here are the things that need to be checked before you start the Ignite backup:

 

  • Is the device file really a tape?
  • Is there a tape inserted in the drive?
  • Is the tape write-protected?
  • Is the tape busy with another program?

Now the make_tape_recovery program can be run. Additionally, the steps above and the MTR command should be logged in case of a problem and ideally, an email sent to the system administrators. I have attached a script that accomplishes all of these tests and writes the results into the file /var/adm/mtr.log. You can store the file in /usr/contrib/bin/mtr and schedule it in cron like this:

 

1 1 * * 0 /usr/contrib/bin/mtr /dev/rmt/0mn admins@mycompany.com

 

That above will run the backup every Sunday at 1:01am.



Bill Hassell, sysadmin