您的位置:首页 > 其它

利用cron监视后台进程状态(二)

2017-08-23 13:41 393 查看
第二种方案:更改系统级的crontab

1. 命令行输入:$sudo vim /etc/crontab

最后一行添加:*  *    * * *   root    bash /home/test/wanda_img_store/backends/bin/cron_worker.sh  ,记得一定要添加user:root,否则不生效!

1 # /etc/crontab: system-wide crontab
2 # Unlike any other crontab you don't have to run the `crontab'
3 # command to install the new version when you edit this file
4 # and files in /etc/cron.d. These files also have username fields,
5 # that none of the other crontabs do.
6
7 SHELL=/bin/sh
8 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
9
10 #m h dom mon dow user   command
11 17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
12 25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
13 47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
14 52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
15 *  *    * * *   root    bash /home/test/wanda_img_store/backends/bin/cron_worker.sh
16 #
~
~
~
~
~
~
~


2. 需要crontab需要重载刚才的文件;命令行输入:$sudo service cron reload/restart 

3. 查看更改的是否生效,$sudo crontab -l
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐