[英]I can't set cron job
I've tried to set a cron job in "crontab -e" : 我试图在“ crontab -e”中设置cron作业:
* * * * * /usr/bin/php /home/vagrant/Code/xxx/testCron.php
testCron.php file creates another file, it contains only this: testCron.php文件创建另一个文件,它仅包含以下内容:
<?php
$f = fopen('cron-' . date('H-i-s') . '.txt', 'w+');
fwrite($f, 'asdf');
fclose($f);
But the file cron-....txt doesn't appear. 但是文件cron -.... txt没有出现。 Were can be a problem?
可能是个问题吗?
I did/checked this: 我做了/检查了这个:
You can check the log from cron jobs to identify errors. 您可以检查cron作业中的日志以识别错误。
Depending on your system, the cron log can be located in different places. 根据您的系统,cron日志可以位于不同的位置。 Find the files containing cron logs:
查找包含cron日志的文件:
grep -ic cron /var/log/* | grep -v :0
./auth.log:1246
./auth.log.1:3054
./bootstrap.log:3
./syslog:187
./syslog.1:220
Then view the contents of the log in question, eg via cat
: 然后查看相关日志的内容,例如通过
cat
:
cat /var/log/syslog
Or view the latest run of testCron.php in that file: 或在该文件中查看testCron.php的最新运行:
grep -i testCron.php /var/log/syslog | tail -1
Your script creates the cron-...txt
file with no path; 您的脚本创建没有路径的
cron-...txt
文件; therefore it appears in the current directory - if it has write permission. 因此,它显示在当前目录中-如果具有写权限。 Cronjobs will have a different start directory - usually the user's home, but may be anywhere, depending on configuration.
Cronjobs将具有不同的开始目录-通常是用户的家,但可能在任何地方,具体取决于配置。
Try one of these: 尝试以下方法之一:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.