Cron Command not working

Cron Command not working

by David Maldonado -
Number of replies: 12

Greetings Dear Moodlers,

Me again. This time, I have a problem with my cron command. I am running moodle 2.7 on a Ubuntu linux server. On my crontab -e file I have setup the line:

*/1 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php >/dev/null

as suggested in the cron website, however I receive e-mails every time the cron job runs. (every minute)

Looking in other websites I found the line:

*/1 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php  -o /dev/null -silent 

but when I try that I get an error that states: Unrecognised options: -o /dev/null  -silent Please use --help option.

If I use the command:

 */1 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php

Then 
everything runs fine except me and pretty much everyone in the system get an e-mail from my moodle admin account... Any thoughts? what switch am I missing to run this transaction without spamming everyone and myself?


Kind thanks!
DM



Average of ratings: -
In reply to David Maldonado

Re: Cron Command not working

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The first line is right (except that you don't need the /1, every minute is the minimum anyway). 

Presumably, you mean you get an email from cron every time. What does the email say?

In reply to Howard Miller

Re: Cron Command not working

by David Maldonado -

Greetings Howard,


Thanks for your reply. The e-mail is blank. Just comes from my moodle admin account. The sad thing is that even regular users get the e-mail not just admins...

In reply to David Maldonado

Re: Cron Command not working

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
If your problem is the unwanted mail, the old fashioned way is:
m h D M W command > /dev/null 2>&1
In reply to Visvanath Ratnaweera

Re: Cron Command not working

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Although mail being suppressed due to 2>&1 should, by rights, be errors. So, you *might* want to know about it wink

Average of ratings: Useful (1)
In reply to Howard Miller

Re: Cron Command not working

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
I know, I know!
wink

Yes, being explcit is safer with the OP. So the message is, you have the choice, the system allows both. Of course, you need to know/understand/conclude the pros and cons, if at all possible, before making the choice!
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Cron Command not working

by David Maldonado -

Thanks for your suggestion Visvanath,


unfortunately the 2>&1 makes not difference, as soon as cron runs, I get a blank e-mail from my moodle admin account... Any other suggestions on what I could have misconfigured maybe in the GUI tools?


Kind Thanks,

DM

In reply to David Maldonado

Re: Cron Command not working

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
With the ' > /dev/null 2>&1' you get mails? That is really odd. Can you post a screen-shot when you edit crontab ('crontab -u user -e')?

On a philosophical side note: May be GUI gives you "suggestions", but not CLI. There you ask things and get response, i.e. it is interactive. Interactive with the system, not with the community!
smile
In reply to Visvanath Ratnaweera

Re: Cron Command not working

by David Maldonado -

Greetings Visvanath,


Looks like the magic line for me was  /usr/bin/php /var/www/moodle/admin/cli/cron.php  > /dev/null 2>&1 -silent

Not sure why it was working fine for me before, and once the new year kicked in, it didn't like it anymore. But your suggestion plus the -silent did the magic.


I appreciate all your help!
DM

In reply to David Maldonado

Re: Cron Command not working

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi David

Glad that you could solve your problem. Only thing I have a problem now: Where does that '-silent' come from?

Is it still the Ubuntu Server? I wonder whether it is something specific to Ubuntu?
In reply to Visvanath Ratnaweera

Re: Cron Command not working

by David Maldonado -

well... not so lucky see screenshot below. Back to square one. Do you think it has to do with me putting the setting up cron under the roon crontab rather than the www-data crontab?


DM

Attachment contab.JPG
Attachment cron.JPG