FreeBSD uses crontab timer to shut down the machine

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.