HP-UX - General

Re: howto run a script from cron every 5 minutes except 11pm-8am

 
SOLVED
Go to solution
'chris'
Super Advisor

howto run a script from cron every 5 minutes except 11pm-8am

hi

howto run a script from cron every 5 minutes except 11pm-8am ?

kind regards
chris
7 REPLIES 7
harry d brown jr
Honored Contributor
Solution

Re: howto run a script from cron every 5 minutes except 11pm-8am

1,6,11,16,21,26,31,36,41,46,51,56 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * * cmd

live free or die
harry d brown jr
Live Free or Die
'chris'
Super Advisor

Re: howto run a script from cron every 5 minutes except 11pm-8am

or is it correct like this:

*/5 8-22 * * * /path/to/the/script

?
Mic V.
Esteemed Contributor

Re: howto run a script from cron every 5 minutes except 11pm-8am

The 8-22 part will be fine. I've never seen syntax like */5. It sure would be nice if that worked! Saves a lot of hassle.

From the man page:

Each pattern can be either an asterisk (*), meaning all legal values, or a list of elements separated by
commas. An element is either a number in the ranges shown above, or two numbers in the range
separated by a hyphen (meaning an inclusive range). Note that the specification of days can be made in
two fields: monthday and weekday. If both are specified in an entry, they are cumulative.

Mic
What kind of a name is 'Wolverine'?
Patrick Wallek
Honored Contributor

Re: howto run a script from cron every 5 minutes except 11pm-8am

The */5 is a Linux thing and does NOT work in HP-UX.

The responses the others have given will work.
'chris'
Super Advisor

Re: howto run a script from cron every 5 minutes except 11pm-8am

thanks !
Ross Minkov
Esteemed Contributor

Re: howto run a script from cron every 5 minutes except 11pm-8am

I know */5 works in Linux for sure. Don't know about HP-UX... Another way to write the same (every 5 minutes) in Linux is 0-59/5. It's easy to test...

Regards,
Ross
Greg OBarr
Regular Advisor

Re: howto run a script from cron every 5 minutes except 11pm-8am

You could also just run it every 5 minutes and have the script check the time when it runs. If the hour is within range, continue the script. If the hour is out of range, exit and do nothing.