cron job

cron job

autor Eman Ibrahim -
Počet odpovědí: 7

Hello, 

I use Hostinger with moodle and I have a problem in setting up cron job. It works only manually in the web browser. Although I create a cron job in hostinger to run automatically, it doesn't work. Please advise. 

Thanks

Průměr hodnocení: -
V odpovědi na Eman Ibrahim

Re: cron job

autor Ken Task -
Obrázek: Particularly helpful Moodlers
V odpovědi na Ken Task

Re: cron job

autor Eman Ibrahim -

I tried to google as well and asking Hostinger support. The same steps are followed but in vain. 

V odpovědi na Eman Ibrahim

Re: cron job

autor Ken Task -
Obrázek: Particularly helpful Moodlers

So Hostinger support told you what?

Mind sharing a screen shot of what you do have setup?

'SoS', Ken

V odpovědi na Ken Task

Re: cron job

autor Eman Ibrahim -
Thanks so much for your support
I figured out what it should be like after many trials. This is for future reference. Cron job must look like this in Hostinger:
/domains/your-domain.com/public_html/admin/cli/cron.php
If Moodle is set up inside a folder, it should be added after public_html
V odpovědi na Eman Ibrahim

Re: cron job [SOLVED]

autor Visvanath Ratnaweera -
Obrázek: Particularly helpful Moodlers Obrázek: Translators
[SOLVED] Thanks for posting the solution.

You never said how you had the crontab configured. As you've found out, it is safer to user the full path (absolute path) in crontab. If you follow the link Ken has posted, it has the absolute path of the PHP interpreter and the path to PHP script started with public_html/. Apparently your hosting environment adds your "home", /domains/your-domain.com, if not an absolute path. Still the absolute path is the safest because another environment may behave differently.
V odpovědi na Visvanath Ratnaweera

Re: cron job [SOLVED]

autor umar mughal -

One very important detail that I would like to add to this solution although this is well described:

In case you are using sub domain for Moodle i.e., moodle.abcd.com, etc, then the correct path still would include the domain name, not the subdomain name. For that, you are going to put the subdomain directory name (inside public_html, it is moodle) instead. So that correct path becomes:

domains/abcd.com/public_html/moodle/admin/cli/cron.php

Thank you
I hope it will help to whoever is struggling, I spent multiple hours as well but it is worth the time.

V odpovědi na Eman Ibrahim

Re: cron job

autor Ken Task -
Obrázek: Particularly helpful Moodlers

Thanks for sharing back info.

Important to emphasize ... "If Moodle is set up inside a folder, it should be added after public_html"

That means there is something above ... up one level ... in public_html.   A static page? or a WordPress (WP)?

If WP there is a 'catch 22'.   Note the IF!  WP uses .htaccess files.  Those files are hierarchical ... the top level .htaccess file rules apply to all files/folders (including in this case a 'moodle' directory).   Those rules are for WP ... not for the moodle ... and those WP rules can disrupt a moodle.

'SoS', Ken