Using cron to realize automatic restart of Linux system __linux

Source: Internet
Author: User

Purpose: because the server is running for a long time, it may cause some programs to occupy too much resources, so it requires a server reboot.

Implementation method:

Use the Cron service to view the Cron service status with service Crond State, or service Crond start if it is not started,

A cron service is a timed service that can be added to or edited by the crontab command to perform tasks that need to be performed regularly:

Crontab-u//Set a user's Cron service, which is required by the general root user when executing this command

CRONTAB-L//list details of a user's cron service

Crontab-r//Remove cron service for no users

CRONTAB-E//Edit a user's cron service

For example, root view your cron settings: Crontab-u root-l

Again for example, Root wants to delete Fred's cron settings: Crontab-u fred-r

When editing a cron service, there are some formatting and conventions for editing the content, input: Crontab-u root-e

into the vi editing mode, the contents of the edit must conform to the following format: */1 * * * * ls >>/tmp/ls.txt

Edit the/etc/crontab file with one line at the end: 5 * * * Root init 6 This configures the system to automatically restart at 5-point 30 per morning.

you need to set up the Crond service that starts automatically after the system starts, and can be added at the end of the/etc/rc.d/rc.local

Service Crond Start

If you also need to load additional services at the system start ten, you can continue to add the start command for other services.

For example: Service mysqld start

Other content can refer to: http://linux.21ds.net/2005/03/15/38380bcac587b0e67b28eef794c7b0d1/

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.