1826204 Members
2974 Online
109691 Solutions
New Discussion

Re: cron capabilities

 
SOLVED
Go to solution
Gerry Tully
Frequent Advisor

cron capabilities

Does anyone know of a way to have a system reboot at a certain time on say the third Friday of every month? The problem I am running into is that these fall on different dates during the months. Thanks.
Any Ideas?
15 REPLIES 15
Antoanetta Naghiu
Esteemed Contributor

Re: cron capabilities

You can run cron as root or better at.
Also, SAM->Routine Tasks->Sytem Shutdown let you to enable a shoutdown a while ago.
Rick Garland
Honored Contributor

Re: cron capabilities

Can do last day of month. Not aware of capabilities to do this unless you script something and use some arrays.
Gerry Tully
Frequent Advisor

Re: cron capabilities

That's what I thought I would have to do but I was hoping someone knew a better way.
Any Ideas?
John Palmer
Honored Contributor

Re: cron capabilities

Write a script and cron it to run on every Friday.

At first thought, if the date is then between the 15th and 21st inclusive then it's the 3rd in the month.
John Palmer
Honored Contributor

Re: cron capabilities

Sorry Gerry,

I meant to finish...

if todays date obtained from 'date' is between the 15th and 21st inc then do your reboot:-

shutdown -r -y 0

otherwise just exit.
CHRIS_ANORUO
Honored Contributor

Re: cron capabilities

Try this and remark for other weeks.

30 5 * * 6 /sbin/shutdown -r 0
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Victor BERRIDGE
Honored Contributor
Solution

Re: cron capabilities

in your cron you could place a line:
00 04 * * 5 /your_script

And in your script, test the value of the date, I suppose a 3rd friday in the month should be between the 17th and 23rd day of the month (check it out!)
like:
if [ $(date '+%d') -lt 23 ] and [ $(date '+%d' -gt 17 ]
then

fi
Rick Garland
Honored Contributor

Re: cron capabilities

For December of this year, the 3rd Friday is the 15th
Victor BERRIDGE
Honored Contributor

Re: cron capabilities

And I made a mistake in the syntax, lest say:

if [ $(date '+%d') -lt 23 -a $(date '+%d') -gt 15 ]
then...

Regards
Victor
Victor BERRIDGE
Honored Contributor

Re: cron capabilities

And I made a mistake in the syntax, lets say:

if [ $(date '+%d') -lt 23 -a $(date '+%d') -gt 15 ]
then...

Regards
Victor
curt larson
Frequent Advisor

Re: cron capabilities

as john palmer has correctly pointed out, the 3rd Friday occurs on the 15th thru the 21st incusive. This equates to gt 14 and lt 22.
nobody else has this problem
curt larson
Frequent Advisor

Re: cron capabilities

as john palmer has correctly pointed out, the 3rd Friday occurs on the 15th thru the 21st incusive. This equates to gt 14 and lt 22.
nobody else has this problem
curt larson
Frequent Advisor

Re: cron capabilities

as john palmer has correctly pointed out, the 3rd Friday occurs on the 15th thru the 21st incusive. This equates to gt 14 and lt 22.
nobody else has this problem
curt larson
Frequent Advisor

Re: cron capabilities

as john palmer has correctly pointed out, the 3rd Friday occurs on the 15th thru the 21st incusive. This equates to gt 14 and lt 22.
nobody else has this problem
wyan lowe
Frequent Advisor

Re: cron capabilities

I wrote a hack script that seems to work...
it uses "cal" and cut -c16-17

thought there might be a way to do this via "at"
but guess not.