How can i add a cron job run every minute to my elearning site on moodle?

6.9k views Asked by At

I try to add a cron job on an elearning.mysite.gr(Moodle). Although my host gives this message every hour. Oct 2 1:10:01 linux CROND[123456]: (admin) CMD (touch /tmp/test.txt > /dev/null)

On my site administration -> notifications get this message: The admin/cli/cron.php script has not been run for 3 days 2 hours and should run every 1 min.

At moodle documentation
/path/to/moodle/admin/cli/cron.php, can i use it ? in which way ?

I tried this : /usr/bin/php /path/to/moodle/admin/cli/cron.php

but gives me that the process completed with error at one minute only this touch /tmp/test.txt > /dev/null completed with success.

Moodle Documentation: The CLI (command line interpreter) script. This will be at the path /path/to/moodle/admin/cli/cron.php If in doubt, this is the correct script to use. This needs to be run by a 'PHP CLI' program on your computer. So the final command may look something like /usr/bin/php /path/to/moodle/admin/cli/cron.php You can (and should) try this on your command line to see if it works. WARNING: Check your command-line PHP version is compatible with your chosen version of Moodle.-How to check it? The command-line PHP program is different to the one running your web site and is not always the same version.

I don't know what to do...I will appreciate any help!!!

I tried by my host panel interface :

Type of progress:

  1. Command line
  2. URL
  3. PHP i should choose one from 3.

Command*: placeholder to add my command to be excecuted

Excecute: Dropdown 1.Cron style 2.Daily at 00:00

I use command line. touch /tmp/test.txt When i add cron style and 1 * * * * * , get message for syntax. and for daily at 00:00 success message but on my notification of my site has The admin/cli/cron.php script has not been run for 17 days 22 hours and should run every 1 min.

enter image description here

That's the icon of my Plesk Login. To change the path/to/moodle/admin/cli/cron.php xould i check the file manager in order to find cron.php file ??

enter image description here

2

There are 2 answers

5
Ludo On

As you add the cron from a web interface (maybe Plesk ?) you only need this part:

 /path/to/moodle/admin/cli/cron.php

replace /path/to/moodle/ with the real path on your server, usulay something like /var/www/moodle/ or /var/www/vhosts/domain.name/httpdocs/moodle

To run every 1 minute cron style is :

* * * * * 

If you can choose PHP version, choose the same version as the one you are using for Moodle.

0
Tom Pit On

Finally, I give this touch /tmp/test.txt ->and at cron style the touch /tmp/test.txt, as you suggest to me.

Because the other commands cannot complete with success. But in my notifications,(Site administration-Moodle) i still get the message that cron don't run.