dpnhp20440 2018-09-26 20:05
浏览 113

Cron设置正确(我认为)但没有运行

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条回答 默认 最新

  • doupingpeng7567 2018-09-27 10:03
    关注

    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!

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?