我完全无助,完全绝望。
在创建以下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)中。
我做错了什么?
发布于 2022-07-03 14:08:55
*/15 * * *看起来不像是一个有效的间隔。
假设您希望每15分钟执行一次命令,您还应该指定一周中的一天。
Crontab条目结构:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │ 7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>这可能是有用的:https://crontab.guru/
发布于 2022-07-03 17:31:00
我找到了,我很想鞭打自己。在无数次的首次亮相之后,我碰到了这条线:
define('SERVER_USERNAME', trim(getenv('USER')));当然,如果您不使用cron运行它,这会非常好,因为$USER在那里是空的。
我把它换成了:
define('SERVER_USERNAME', trim(exec('whoami')));瞧,瞧。一切都正常。
https://stackoverflow.com/questions/72846736
复制相似问题