[英]Running PHP File on a Cronjob in cPanel
我有一个名为automate.php的文件,带有mysql连接字符串和一些PHP / SQL查询,我想在Cronjob上运行该文件。
我试过使用完整的URL,如:
http://www.domain.com/script.php
本地路径:
/home/your_username/public_html/script.php
并且:
php -f -q /home/your_username/public_html/script.php
我每次运行时都收到一封电子邮件,它只是说: 没有指定输入文件。
我究竟做错了什么?
使用此命令
每5分钟
*/5 * * * * wget http://www.domain.com/script.php
这听起来像是权限问题。 确保cron runner用户对此php文件具有可执行权限。 同时使文件可执行:
chmod +x /path/to/script.php
在文件的顶部添加:
#! /usr/bin/env php
现在脚本应该能够自己运行:
*/5 * * * * /path/to/script.php
你应该有你的服务器域+你的脚本路径,即http://server.domain.net/myscriptfolder/script.php这是你的托管/域名提供商的http://server.domain.net absolut域名。 在我的情况下,这有效...
使用此命令
php-cli script.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.