gerrymac1943
asked on
cron job every day to reboot at 04:00?
Experts,
I want to use cron to reboot at 04:00am, every morning for my linux ubuntu pc.
Can some one confirm how you would do this using cron?
Cheers
GMac
I want to use cron to reboot at 04:00am, every morning for my linux ubuntu pc.
Can some one confirm how you would do this using cron?
Cheers
GMac
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are also some tools available:
http://kshutdown.sourceforge.net/
http://manpages.ubuntu.com/manpages/maverick/man1/qshutdown.1.html
https://launchpad.net/complexshutdown
etc.
wmp
http://kshutdown.sourceforge.net/
http://manpages.ubuntu.com/manpages/maverick/man1/qshutdown.1.html
https://launchpad.net/complexshutdown
etc.
wmp
ASKER
i've tested both suggestions separately and they don't work....
0 4 * * * /sbin/init 6
&
0 4 * * * shutdown -r now
Note to test I reset time using date -s 03:59, but the linux pc did not reboot when it reached 04:00
0 4 * * * /sbin/init 6
&
0 4 * * * shutdown -r now
Note to test I reset time using date -s 03:59, but the linux pc did not reboot when it reached 04:00
After resetting the time you'll have to restart the cron daemon, afaik, to make the new time known to ut.
wmp
wmp
Make sure the cron daemon is running. If it is up and running, it should read the time without restarting.
check:
ps -ef | grep cron
Also check the /var/spool/cron*/* directory:
cat /var/spool/cron*/*
check:
ps -ef | grep cron
Also check the /var/spool/cron*/* directory:
cat /var/spool/cron*/*
You'll need to set a user to run as, and a full path to the shutdown command, so:
0 4 * * * root /sbin/shutdown -r now
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can make it run as root if you are either:
issue this command as root
crontab -e
Or
sudo crontab -e -u root
That would make the above commands work.
issue this command as root
crontab -e
Or
sudo crontab -e -u root
That would make the above commands work.
ASKER
i have followed the following procedure using the commands:
1. opened crontab as root
fcrontab -e
2. entered reboot command which allow reboot at 04:00 every day.
0 4 * * * shutdown -r now
( and also 0 4 * * * /sbin/init 6)
3. set date to 03:59 to test reboot
date -s 03:59
4. restarted crontab
/etc/init.d/cron restart
However the linux ubuntu pc still does not reboot at 04:00
1. opened crontab as root
fcrontab -e
2. entered reboot command which allow reboot at 04:00 every day.
0 4 * * * shutdown -r now
( and also 0 4 * * * /sbin/init 6)
3. set date to 03:59 to test reboot
date -s 03:59
4. restarted crontab
/etc/init.d/cron restart
However the linux ubuntu pc still does not reboot at 04:00
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
xterm it seems to work @ 4pm thanks when i checked the log file!
Nov 8 04:00:00 ubuntu fcron[1969]: SIGTERM signal received
Nov 8 04:00:00 ubuntu fcron[1969]: SIGTERM signal received
sudo crontab -e
Then modify
0 4 * * * /sbin/init 6
Save and exit