"Raspberry Pi" crontab set Linux device timed restart

Source: Internet
Author: User

Summary: Set Linux devices to restart or shut down periodically

Problem: A person who always needs to use a device on a daily basis to manually reboot to work properly, but check the log, it seems that the service is normal. The time and the correct time differ by 4mins.

Workaround:

1. Increase the scheduled task, set the automatic restart;

2. Modify the correct time, and increase the automatic synchronization;

Are relatively simple commands, here a simple record, can be for the needs of the students reference;

To increase the scheduled task, set the automatic restart:

Edit crontab:

sudo  crontab-e

Add timed restart command to view crontab

[Email protected]:~ $ sudo crontab-l
# Edit This file to introduce the tasks to is run by Cron.
#
# each task to run have to is defined through a single line
# indicating with different fields when the task would be run
# and what command to run for the task
#
# to define the time you can provide concrete values for
# minute (M), hour (h), Day of Month (DOM), month (Mon),
# and Day of the Week (Dow) or use ' * ' in these fields (for ' any '). #
# Notice that tasks would be started based on the Cron ' s system
# daemon ' s notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# Email to the user of the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m. every week with:
# 0 5 * * 1 tar-zcf/var/backups/home.tgz/home/
#
# For more information see the manual pages of crontab (5) and cron (8)
#
# m H Dom Mon Dow command
0 * * * sudo-u root reboot

Restart the service to ensure that it takes effect:

sudo service cron restart

sudo vi/etc/sudoers

Other:

Crontab that require root permission to perform, such as shutdown shutdown required: sudo crontab-e
In the editor, add the following 2 lines, the time is recorded in the log, 22 30 minutes a day to perform the shutdown command, 1 minutes warning will automatically shut down

* * * Date >>/home/haochuang/temp/shutdown.log30 * * * sudo-u root shutdown-h 1

</END>

"Raspberry Pi" crontab set Linux device timed restart

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.