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

来源:互联网 发布:医生收入 知乎 编辑:程序博客网 时间:2024/06/08 04:05

第二种方案:更改系统级的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


原创粉丝点击