Setting up cron on CentOS for Moodle

Setting up a cronjob for Moodle on a CentOS server when you have limited Linux experience can be rather daunting. I still don’t know to much, but the little I know, I’ll share.

To set up the cronjob for Moodle, I used the following command:
sudo crontab -e apache -u

My task – set to run every 15 minutes for now.
*/15 * * * *        /usr/bin/php /var/www/elearning/admin/cli/cron.php >/dev/null

To save and quit the editor, sue the following command:
:wq (colon w q)

Once that’s all set up and saved, you can use the following command to check that it’s there:
sudo crontab -u apache -l

cron

crontab

One last little nugget I’ll share with you, is the viewing of the cron file to verify that the cronjob has run.
The file is located in /var/log and the file is called cron

To view the file:
sudo cat cron

To exit the file, simply press q

Some more file viewing commands:
sudo less filename               – one line at time
sudo more filename
head filename                       –   view the top part of the file
tail filename                           – view the bottom part of the file
tail -10 filename                    – view the last 10 lines

0 thoughts on “Setting up cron on CentOS for Moodle

Leave a Reply

Your email address will not be published. Required fields are marked *