Shell Crontab不工作 [英] Shell Crontab not working
问题描述
GNU nano 2.0.9档案:/tmp/crontab.XXXXzBQgwS
GNU nano 2.0.9 File: /tmp/crontab.XXXXzBQgwS
*/5 * * * * ~/check_phpfpm.sh
*/5 * * * * ~/check_nginx.sh
*/5 * * * * ~/disk-clean.sh
*/5 * * * * ~/loadcheck.sh
右键我的代码应该每5分钟运行一次。但不会运行
By right my code should run every 5 minutes. but it doesn't run
[root@4D13 ~]# ls -l
total 756
-rw-------. 1 root root 1688 Dec 18 09:45 anaconda-ks.cfg
-rwxrwxrwx 1 root root 139 Dec 28 18:18 check_nginx.sh
-rwxrwxrwx 1 root root 140 Dec 28 18:19 check_phpfpm.sh
-rwxrwxrwx 1 root root 456 Dec 28 18:18 disk-clean.sh
-rw-r--r--. 1 root root 15469 Dec 18 09:45 install.log
-rw-r--r--. 1 root root 5267 Dec 18 09:44 install.log.syslog
-rwxrwxrwx 1 root root 503 Dec 19 19:26 loadcheck.sh
drwxr-xr-x 9 1001 1001 4096 Dec 18 11:08 nginx-1.3.2
-rw-r--r-- 1 root root 722119 Jun 26 2012 nginx-1.3.2.tar.gz
[root@4D13 ~]#
它应该运行〜/ check_phpfpm.sh作为我的代码如果我手动运行它将工作
It should run ~/check_phpfpm.sh as my code if i run manually it will work
[root@4D13 ~]#
[root@4D13 ~]# ~/check_phpfpm.sh
Stopping php-fpm: [FAILED]
Starting php-fpm: [ OK ]
更多关于check_phpfpm,检查服务php-fpm是否正在运行,如果它不工作,它将执行并重新启动php-fpm,但问题是如果我手动运行它的工作。但crontab不重新启动,服务器php-fpm崩溃,并进入停止模式,但此脚本不重新启动,我的crontab应该执行脚本每5分钟检查。
More about check_phpfpm, it is a script that check if the service php-fpm is running, if it not working ,it will execute and restart php-fpm, but the issue is if i run manually its work. but the crontab does not restart, the server php-fpm crashed and went to stop mode, but this script does not restart, my crontab should execute the script every 5 mins to check.
我的crontab设置有什么问题?感谢所有帮助
What is wrong with my crontab setup? Thanks for all help
推荐答案
首先确保脚本可执行:
chmod u+x name_of_script
现在将其添加到crontab :
Now add it to crontab:
crontab -e
还要确保你在crontab中写了完整路径,例如:
Also make sure you are writing the full path in the crontab e.g:
*/5 * * * * /home/user/loadcheck.sh
这篇关于Shell Crontab不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!