reboot FreeBSD box with crontab

Hello mfaridi.

To do a scheduled reboot at midnight put to following code into the system contrab file /etc/crontab
Code:
@midnight root /sbin/shutdown -r now
I have not tested this, but it should work. For more information see crontab(5)
 
# shutdown -r now
is preferred because it allows services to stop cleanly.

Fixing the problem is better yet. Clearly it's not a hardware problem. With extra machines, finding the software problem shouldn't be too hard. Set up one machine for a test, make sure it crashes on schedule, change one thing at a time until it doesn't crash on schedule.
 
Better if you will do
Code:
shutdown -r +5
This will broadcast to users about reboot in 5minutes, so they can save their work
 
thanks all guys , but my server is NAT and samba server and I want reboot in midnight when nobody work with their system and and they are in house . if I find way to solve this problem it is better than reboot system before 26 hours
 
wblock@ said:
# shutdown -r now
is preferred because it allows services to stop cleanly.

Fixing the problem is better yet. Clearly it's not a hardware problem. With extra machines, finding the software problem shouldn't be too hard. Set up one machine for a test, make sure it crashes on schedule, change one thing at a time until it doesn't crash on schedule.

Do you think reboot system with crontab is not safe and it can make problem for my system ?
 
how I can check this command work good ,
Code:
@midnight root /sbin/shutdown -r now
because I ma far way from FreeBSD server and connect to FreeBSD box with SSH , I go to my work place in tuseday only . I do my all work remotely with ssh
 
I have just rebooted my machine this way. It worked fine. I can now login via ssh again. You can use ping(8) to see if your machine is reachable, or use "netcat" to see if your ssh server is listening for connections. Like this:
Code:
nc -v -n -z 1.2.3.4 22
Or simply login via ssh ;)
Then you can verify that your machine has rebooted using uptime(1)
 
Back
Top