[英]Cron job command in linux hosting
I have linux hosting on godaddy and I m trying to execute php file through cron command. 我在godaddy上托管了linux,并且尝试通过cron命令执行php文件。 But its not working.
但是它不起作用。 Can anyone help me out from this ?
有人可以帮助我吗? Thanks in advance.
提前致谢。
Cron Command Code : Cron命令代码:
/usr/local/bin/php -q /home/user/folder/file.php / usr / local / bin / php -q /home/user/folder/file.php
Make sure the cron deamon is running and the correct user is running it. 确保cron守护进程正在运行,并且正确的用户正在运行它。 You can try:
你可以试试:
systemctl status crond.service
If it's not running, start it: 如果它没有运行,请启动它:
systemctl start crond.service
Make sure the deamon starts on reboot: 确保重新启动守护进程:
systemctl enable crond.service
Make sure your path to PHP is correct. 确保您的PHP路径正确。 Check the path:
检查路径:
whereis php
Your cron command looks incomplete (missing the run intervals). 您的cron命令看起来不完整(缺少运行间隔)。 Like so:
像这样:
* * * * * /usr/bin/php -q /home/user/folder/file.php
Those asteriks denote the run intervals. 这些星号表示运行间隔。 Use a tool to help you determine the proper run intervals.
使用工具来帮助您确定适当的运行间隔。 Like this one:
像这个:
https://crontab.guru/ https://crontab.guru/
Run crontab under the correct user and edit the cron command. 在正确的用户下运行crontab并编辑cron命令。 For example, here we'll edit the crontab for apache:
例如,在这里,我们将为apache编辑crontab:
crontab -u apache -e
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.