I have a cronjob that looks like this:
30-59/1 13 * * 1-5 /usr/bin/php /home/myproject/main/logic.php 2>&1 >>/home/myproject/main/cronlog.txt
I can run the script fine from the command line.
And I can see it being ran in syslog.
grep CRON /var/log/syslog
Apr 5 18:51:01 ip-x-x-x-x CRON[30277]: (ubuntu) CMD (/usr/bin/php /home/myproject/main/logic.php 2>&1 /home/myproject/main/cronlog.txt)
Permissions:
-rwxrwxr-x 1 root root 4791 Apr 5 18:31 logic.php
In my php file:
require '/home/myproject/main/data.php';
require '/home/myproject/vendor/autoload.php';
But the code in my script is not actually executing.
Any ideas what I'm doing wrong here?
You sending stderr to stdout, but your not sending stdout anywhere. Need to put the > in front of your file.
30-59/1 13 * * 1-5 /usr/bin/php /home/myproject/main/logic.php 2>&1 >/home/myproject/main/cronlog.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.