Heim  >  Artikel  >  Backend-Entwicklung  >  crontab定时执行php file_put_contents无法新建并写到一个文件内 但是自己执行是可以成功的

crontab定时执行php file_put_contents无法新建并写到一个文件内 但是自己执行是可以成功的

WBOY
WBOYOriginal
2016-06-06 20:16:491195Durchsuche

cronjob执行一个php脚本 file_put_contents失败 但是脚本还是执行的 会发邮件 就是无法生成文件
但是自己执行这个脚本ok file_put_contents ok
路径是绝对路径. 用户是root 求解为什么

回复内容:

cronjob执行一个php脚本 file_put_contents失败 但是脚本还是执行的 会发邮件 就是无法生成文件
但是自己执行这个脚本ok file_put_contents ok
路径是绝对路径. 用户是root 求解为什么

你输出下error_log,例如这样 crontab /1 * php your.php > /tmp/crontab_error.log > &1

root用户有权限么?
打开错误报告会比较好定位

root crontab -e
修改执行命令为/usr/local/php/bin/php[你的php的实际路径] -f /脚本的绝对路径.php > /tmp/xxx.log

时间到了查看/tmp/xxx.log内容

对,输出 error_log,然后查看error_log就比较清楚原因了.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn