1830657 Members
29211 Online
110015 Solutions
New Discussion

Re: cron

 
Ramnath S
New Member

cron

Hi,

I need to enter one entry in cron where it will reboot the server on First and Third thursday of every month. Can anyone suggest on this.

Thanks in advance.

Regards
7 REPLIES 7
IT_2007
Honored Contributor

Re: cron

what time you want to reboot the server?
Ramnath S
New Member

Re: cron

04:15 IST time.

Regards
IT_2007
Honored Contributor

Re: cron

You have to write a script to check 1st and 3rd thursday for every month since cron is not user friendly.

For Ex:

15 4 * * 4 /usr/sbin/shutdown -ry 0 >/dev/null 2>&1

Which will reboot server Every Thursday at 4:15am

see more details at

http://docs.hp.com/en/B2355-60127/crontab.1.html
IT_2007
Honored Contributor

Re: cron

Best way is use Clay's script to do your cronjob. See the link for more details.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=371092
Ramnath S
New Member

Re: cron

Thanks for your replies.

Regards
IT_2007
Honored Contributor

Re: cron

If you feel, this forum answered your questions, please assign points and close the thread.
spex
Honored Contributor

Re: cron

Hi,

Schedule this to run every Thursday:

#!/usr/bin/sh
DATE=$(date +u"%d")
TH1=$(cal | awk '{if ($5 != "Th" && $5 != "") print $5}' | head -1)
TH3=$(cal | awk '{if ($5 != "Th" && $5 != "") print $5}' | head -3 | tail -1)
if [ "${DATE}x" = "${TH1}x" -o "${DATE}x" = "${TH3}x" ]
then
shutdown -r -y now
fi
exit

A sample crontab entry (which runs every Thursday at 1:00am):
0 1 * * 4 reboot-1st-3rd-th.sh

PCS