1829407 Members
2170 Online
109991 Solutions
New Discussion

cronjob question?

 
SOLVED
Go to solution
John McDen
Regular Advisor

cronjob question?

I have 2 cron jobs one is for stoping the database before the backup and the other is to start the databases.

I just need that it does not start-up the data base on a one single particular day.

How do I do that ?
New to HP
8 REPLIES 8
Christopher McCray_1
Honored Contributor
Solution

Re: cronjob question?

Hello,

For the job that starts up the db, just exclude the day . for example if that day was Tuesday:

00 06 * * 0,1,3,4,5,6 /start_command

Hope this helps

Chris
It wasn't me!!!!
Dave La Mar
Honored Contributor

Re: cronjob question?

Crontab entry -
#min hour date month day cmnd
00 18 * * 1-3,5-7 start_script

Will run the command start_script
Mon-Wed and Thur-Sun.

Hope this helps.

dl
"I'm not dumb. I just have a command of thoroughly useless information."
James R. Ferguson
Acclaimed Contributor

Re: cronjob question?

Hi John:

The easist way is to skip that day in your crontab. For instance:

00 01 * * 0,1,2,4,5,6 /home/jrf/db.sh

...this would run at 0100 every day but day=3 (or Wednesday).

Regards!

...JRF...
Jeff Schussele
Honored Contributor

Re: cronjob question?

Hi John,

Depends - which day?

Day of the month - say the 21st
1 0 21 * * /path/to/command

Day of week - say Monday
1 0 * * 1 /path/to/command

A particular Monday every month - say the 3rd Monday
1 0 15,16,17,18,189,20,21 * 1 /path/to/command

If you just want to run this say every 21 days the best way is to use the at command & the ending command of the at command would be to make another at command destined for 21 days later.
If it's ONLY once then definitely use that at command.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Dave La Mar
Honored Contributor

Re: cronjob question?

Sorry, Chris is correct on the days ... it is 0-6.
0= Sunday.
I was thinking the date command days.
Use Chris's or a combo.

Embarassed.
"I'm not dumb. I just have a command of thoroughly useless information."
MANOJ SRIVASTAVA
Honored Contributor

Re: cronjob question?

Hi John

There are two ways to do it :

0 6 * * 0 1 2 3 4 6 /

not to run on day 5 ie friday

or run it for the other days individually.


Manoj Srivastava
John McDen
Regular Advisor

Re: cronjob question?

Thanks to all of you ...
New to HP
Jeff Schussele
Honored Contributor

Re: cronjob question?

Whoops...misread & a typo...sheesh...

Yes just exclude the day from command. Earlier responses are right on.

But let's add the xth day of the month
Let's say the 21st
1 0 1-20,22-31 * * /path/to/start_command

Now let's say the x day of the xth week
In this case the 3rd Monday
1 0 1-14,22-31 * 1 /path/to/start_command

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!