Skip to content

Instantly share code, notes, and snippets.

@willwhui
Created July 19, 2018 14:57
Show Gist options
  • Save willwhui/1c43eac00b86ae69779dcde604e482d9 to your computer and use it in GitHub Desktop.
Save willwhui/1c43eac00b86ae69779dcde604e482d9 to your computer and use it in GitHub Desktop.
linux系统定时重启
linux系统定时重启
@willwhui
Copy link
Author

willwhui commented Jul 19, 2018

打开linux自带的定时任务管理工具(的配置文件):

sudo crontab -e

在文末添加

0 4   *   *   *    /sbin/shutdown -r +5

意思是每天早上4点+5分钟,调用命令/sbin/shutdown -r来重启设备。
注意:
据说+5必须写。
否则会导致4点钟的时候不停地重启。
因为系统来不及更新当前时间,每次启动之后都会认为现在是4点。
因此,理论上来说,只要能够延迟1秒钟执行重启,都是可行的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment