Cron is setup correct (I think) but is not running

[亡魂溺海] 提交于 2020-01-03 05:22:11

问题


I have set some commands in my crontab, but it seems like they are not executed.

  • PHP version is 7+
  • CentOS 7

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

username is an existing user and has rights to the PHP files. Same results when I use the root user.

When I run "Which php" I get the result below:

/usr/bin/php

So that seems to be OK too.

/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)

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?


回答1:


Alright, it is working... Still not 100% sure why it was not before. But this is what I changed:

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!

Difference was that I used /etc/crontab directly and not using 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!



来源:https://stackoverflow.com/questions/52525312/cron-is-setup-correct-i-think-but-is-not-running

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!