简体   繁体   中英

Why is my cron job not running?

I am trying to run a cron job at 5:20pm as below but it's not working.

20 17 * * 1 /usr/bin/php /home/myacc/public_html/job/generate.php

I basically did crontab -e and entered the above line there and saved the file.

If I try running the command directly from the command line as below, it works fine:

php /home/myacc/public_html/job/generate.php

What am I doing wrong?

Also, how do I send a message from the cron to either a log file or email so that I know what's going on?

You can record all the logs of your cronjobs by installing postfix and configuring it as local domain during installation. Such that you can see the logs of your cron jobs by vi /var/mail/<user-name> . Try looking the logs and figure out the problem. If you don't find any solution post the log so that it will help others to diagnose the problem. I'm adding this as an answer instead of comment because i think I'm answering your second query.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM