Linux定时重启

定时任务crontab

一、编辑cron

命令行 crontab -e 进入编辑模式.
每天6点自动重启,文件内容如下:

0 6 * * * reboot

:wq保存 , q!退出不保存

二、重启cron和服务器

/etc/init.d/crond restart

创建自启动任务

chkconfig --levels 35 crond on

service crond status 查看 cron服务状态,
如果没有启动则 service crond start启动它, cron服务是一个定时执行的服务,可以通过crontab 命令添加或者编辑需要定时执行的任务

补充说明

usage:  crontab [-u user] file
    crontab [-u user] [ -e | -l | -r ]
        (default operation is replace, per 1003.2)
    -e  (edit user's crontab)
    -l  (list user's crontab)
    -r  (delete user's crontab)
    -i  (prompt before deleting user's crontab)
    -s  (selinux context)

评论