2

I am checking if the server is doing cronjob as it's expected.

I have the following code. But I am not sure if it is doing the repeated job or not. I suspect not.

The cron.php is working fine. If I visit with a browser, it shows the results.

Could anyone tell me how I can know if it is doing the job?

I thought sending email notice to me is one idea.

How can I send email to me with the results?

Or is there better ways to check it?

*/10 * * * * /usr/bin/wget http://myschool.moodle.org/admin/cron.php

2 Answers 2

4

From the cron man page:

When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists).

Just add the following line to the beginning of your crontab:

MAILTO=username
0

You can check in your system log if the cron job is running or not, see files in /var/log, depending of your distribution the file may change but generally /var/log/cron is the right place to check.

If you want more information on how the job has been done, the best would be to send an email inside your php script so that you can correctly set the email body with failed or ok result as well as useful information.
You could also send email directly from cron, but as you use wget you will not be able to know if the script as run correctly or not (you can just know that it has run or not, not if something has been wrong in it)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .