我是通过cron工作安排和运行脚本的问题。 我在Linux上(Ubuntu的),这是一个VPS。 我正在做的是我把这一行放在这里的crontab文件:/ etc / crontab我写道:
*/15 * * * * www-data php /var/www/abs/phpscript.php
我已经给了文件777,并在crontab中写上面,我运行命令:
crontab crontab
几乎有一段时间后,我在/ var / mail / username文件中find了这样的邮件:/ bin / sh:root:not found
所以我不明白是什么问题。
我也运行phpinfo,它显示第三个variables为APACHE,这可能意味着PHP作为apache模块运行。
请告诉可能的解决scheme。
提前感谢每一位将尽力解决我的问题的人。
如果编辑了/etc/crontab
,则应该重新读取文件顶部的警告 :
# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do.
在/etc/crontab
文件上运行crontab(1)
可能会污染root 用户的 crontab(5)
文件(存储在/var/spool/cron/crontabs/
)。 我建议以root身份运行crontab -e
来编辑crontab文件,并删除所有与/etc/crontab
的条目相同的条目。 ( 也许你只是沾染自己的个人crontab(5)
– 如果crontab -e
作为root没有显示任何东西,请在你自己的个人帐户下运行crontab -e
,看系统范围的条目是否被复制到你自己的crontab(5)
。)
我不知道你运行chmod 777
文件是什么,但这可能是不必要的。 您应该尽可能严格地设置您的权限,以限制恶意攻击的结果或无意的错误。
您也可以尝试使用“wget -q -O”来运行它
要么
*/15 * * * * lynx -dump "url" > /dev/null
Wget例子:
*/15 * * * * wget -O /dev/null 'http://www.mydomain.com/document.php?&user=myuser&password=mypass' >/dev/null
如果您需要发布数据,您可以使用
–post-data“login = user&password = pass”
*/15 * * * * wget -O /dev/null 'http://www.mydomain.com/document.php?&user=myuser&password=mypass' --post-data 'foo=bar' >/dev/null
您正在以用户身份运行crontab,这意味着您不能在cron中指定用户。
您借用您的示例的模板是用于系统(root)cron。
删除用户名,然后重试。