Cron-Job不执行PHP PHAR
我完全无助,绝望。
创建以下crontab之后:
SHELL=/bin/bash
PHAR="/usr/bin/php -f /home/heimathafen/customfiles/scripts/7d2d.phar"
# m h dom mon dow command
*/15 * * * * ${PHAR} maintenance
*/5 * * * * ${PHAR} monitor
#50 3,7,11,15,19,23 * * * ${SDTD} reboot
#0 * * * * ${PHAR} backup
#55 23 * * 6 ${PHAR} creategifts
* * * * * ${PHAR} gameevents 0
* * * * * ( sleep 10; ${PHAR} gameevents 1)
* * * * * ( sleep 20; ${PHAR} gameevents 2)
* * * * * ( sleep 30; ${PHAR} gameevents 3)
* * * * * ( sleep 40; ${PHAR} gameevents 4)
* * * * * ( sleep 50; ${PHAR} gameevents 5)
我发现这些作业都没有执行。 当我在CLI上运行命令时:
/usr/bin/php -f /home/homeport/customfiles/scripts/7d2d.phar monitor
一切正常。无论我是在它周围放置sh -c“ ...”
还是这样运行。
PHAR文件具有正确的权限(chmod a+x
),并且路径是正确的。 crontab也在UserContext(HomePort)中。
我在做什么错?
I am totally helpless and sheer despair.
After I created the following crontab:
SHELL=/bin/bash
PHAR="/usr/bin/php -f /home/heimathafen/customfiles/scripts/7d2d.phar"
# m h dom mon dow command
*/15 * * * * ${PHAR} maintenance
*/5 * * * * ${PHAR} monitor
#50 3,7,11,15,19,23 * * * ${SDTD} reboot
#0 * * * * ${PHAR} backup
#55 23 * * 6 ${PHAR} creategifts
* * * * * ${PHAR} gameevents 0
* * * * * ( sleep 10; ${PHAR} gameevents 1)
* * * * * ( sleep 20; ${PHAR} gameevents 2)
* * * * * ( sleep 30; ${PHAR} gameevents 3)
* * * * * ( sleep 40; ${PHAR} gameevents 4)
* * * * * ( sleep 50; ${PHAR} gameevents 5)
I found that none of these jobs are executed.
When I run the command on the CLI:
/usr/bin/php -f /home/homeport/customfiles/scripts/7d2d.phar monitor
everything works fine. No matter if I put an sh -c "..."
around it or just run it like that.
The phar file has the right permissions ( chmod a+x
) and the path is correct.
Also the crontab is in the usercontext (homeport).
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
*/15 * * * *
看起来不像有效的间隔。假设您想在每15分钟执行命令,则还应指定一周中的一天。
crontab输入结构:
这可能很有用: https://crontab.guru/
*/15 * * *
doesn't look like a valid interval.Assuming that you want to execute your command at every 15th minute, you should also specify the day of the week.
Crontab entry structure:
This might be useful: https://crontab.guru/
我找到了它,很想鞭打自己。
在无数的调试之后,我遇到了这一行:
当然,如果您不用Cron运行它,则可以很好地工作,因为
$ user
在那里空了。我替换为:
lo and to。一切都起作用。
I found it and would love to whip myself.
After countless debugs I came across this line:
Of course, this works beautifully if you don't run it with cron, because
$USER
is empty there.I replaced it with:
and lo and behold. Everything works.