Linux CentOS設置定時重啓:crontab

上一篇介紹了 開機自啓動chkconfig命令  http://www.javashuo.com/article/p-hwpocjtl-gk.htmlhtml

本篇介紹 crontab 設置定時任務,而且把 crontab 加入到開機自啓動中。java

一、配置一個天天自動重啓的功能:linux

若是支持crontab 可直接 crontab -l 查看目前已有的定時任務spa

若是當前的linux不支持crontab 則須要進行配置:rest

#安裝Crontab 
yum install vixie-cron crontabs
#設置開機啓動Crontab 
chkconfig crond on
#啓動Crontab 
service crond start

先列一下現有的Crontab看看:code

crontab -l

提示爲 no crontab for roothtm

啥也沒有,那就添加一條吧:blog

編輯命令:crontab

crontab –e

按  i  進入編輯模式,輸入get

30 15 * * * /sbin/reboot

表示 天天下午15:30分重啓設備。按ESC 進入命令模式,輸入:wq 保存退出。

最後重啓crontab,使重啓功能生效

service crond restart

完事 收工!

補充:Crontab基本格式:

*  *  *  *  *  command

分 時 日 月  周  命令

第1列表示分鐘1~59 每分鐘用或者 /1表示

第2列表示小時1~23(0表示0點)

第3列表示日期1~31

第4列表示月份1~12

第5列標識號星期0~6(0表示星期天)

第6列要運行的命令
相關文章
相關標籤/搜索