我正在运行ubuntu服务器,并尝试每小时运行一个脚本。我尝试的是:
sudo crontab -e
然后我把这个添加到文件的末尾:
MAILTO="info@email.com"
30 * * * * /usr/bin/php /var/www/scripts/cronscript.php
脚本似乎没有运行,我也没有收到电子邮件
我做错了什么?
使用php的-f
标志告诉它将该文件作为输入:
MAILTO="info@email.com"
30 * * * * /usr/bin/php -f /var/www/scripts/cronscript.php
当然,如果您的php实际位于/usr/bin
使用:
30 * * * * /usr/bin/wget "http://example.com/scripts/cronscript.php"
为我工作
您也可以使用cURL,如下所示:
curl http://foobar.com/scripts/cronscript.php
如果你需要它安静地运行:
curl --silent http://foobar.com/scripts/cronscript.php
添加Gzip处理:
curl --compressed http://foobar.com/scripts/cronscript.php
我通常两者都用,比如:curl--静音--压缩http://foobar.com/scripts/cronscript.php