Cron安装正确(我认为),但未运行 [英] Cron is setup correct (I think) but is not running
问题描述
我在crontab中设置了一些命令,但似乎未执行。
I have set some commands in my crontab, but it seems like they are not executed.
- PHP版本为7+
- CentOS 7
这是我运行 crontab -u username -l时的列表/ p>
This is my list when I run "crontab -u username -l"
45 0 * * * username /usr/bin/php /var/www/production/site/scripts/process1.php
*/2 * * * * username /usr/bin/php /var/www/production/site/scripts/process2.php
25 * * * * username /usr/bin/php /var/www/production/api/scripts/process3.php
用户名是现有用户,并有权PHP文件。使用root用户时,结果相同。
username is an existing user and has rights to the PHP files. Same results when I use the root user.
运行哪个php时,结果如下:
When I run "Which php" I get the result below:
/usr/bin/php
这似乎
/ var / log / cron向我显示了这样的行,因此它似乎被称为
/var/log/cron shows me lines like this, so it appears to be called
CROND[29053]: (username) CMD (username /usr/bin/php /var/www/production/site/scripts/process1.php)
当我手动运行命令时,所有命令都运行良好,因此processx.php文件似乎正常。
When I run the commands manually all works well, so the processx.php files seem to be OK.
我没什么主意了……有人能指出我正确的方向来解决我的(可能是愚蠢的)错误吗?
I am running out of ideas... Can anybody point me to the right direction to tackle my (probably silly) mistake?
推荐答案
好的,它正在工作...仍不是100%知道为什么以前没有。
但这是我所做的更改:
Alright, it is working... Still not 100% sure why it was not before. But this is what I changed:
使用命令 crontab -e删除了进程,并删除了其中的3条命令。
然后:
removed the processes with the command "crontab -e" and deleted the 3 commands there. Then:
nano /etc/crontab
在那里添加了命令(由正确的用户执行)!
Added the commands there (with the right user to execute them) e voila!
区别是我直接使用/ etc / crontab而不使用crontab -e。
Difference was that I used /etc/crontab directly and not using crontab -e.
虽然我现在仍然很好奇为什么这行得通,而我通过crontab -e进行的第一次尝试却没有...所以,如果有人知道原因,请让我知道!
Although I am now still curious why this is working and my first attempt through crontab -e is not... So, if anybody knows why, please let me know!
这篇关于Cron安装正确(我认为),但未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!