Introduction:
The company issued a notice said to power outage, OA system backup power can not be long-time support, so to early stop OA server, previously do Windows scheduled task shutdown, now to use crontab to realize the timing of FreeBSD shutdown.
First wrote a shutdown.sh shutdown script.
#! /bin/shshutdown-p now
Run the test directly on the virtual machine, the effect is good, turn it off immediately.
CRONTAB-E, put it in there right now.
*/2 * * * * sh/shell/shutdown.sh
Here I to test so set up two minutes to run once, to their own written crontab not trust can be verified.
Verify the crontab online tool http://tool.lu/crontab/http://www.atool.org/crontab.php
Crontab will not take effect immediately after Setup is finished, you can restart cron with a command
/etc/rc.d/cron restart
After a while, the machine is still running, and not shutting down, looking at the cron logs
Tail-f/var/log/cron
Log inside is a running record, I also check the data to try a lot of methods, are unsuccessful, finally I in a group of FreeBSD asked to get the answer.
#! /bin/sh/sbin/init 0 Power off/sbin/init 6 reboot
At this point, the timer shutdown is realized.
Experience:
Some things, although it seems so simple to listen to others, but in their own attempts to find a lot of their shortcomings, things do not think so good, but it is not so bad.
FreeBSD uses crontab timer to shut down the machine