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

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

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

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就比较清楚原因了.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn