cron job

cron job

Eman Ibrahim發表於
Number of replies: 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

評比平均分數: -
In reply to Eman Ibrahim

Re: cron job

Ken Task發表於
Particularly helpful Moodlers的相片

I don't host with Hostinger, but I can Google!

Does this help:

https://support.hostinger.com/en/articles/1583465-how-to-set-up-a-cron-job-at-hostinger

'SoS', Ken

In reply to Ken Task

Re: cron job

Eman Ibrahim發表於

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

In reply to Eman Ibrahim

Re: cron job

Ken Task發表於
Particularly helpful Moodlers的相片

So Hostinger support told you what?

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

'SoS', Ken

In reply to Ken Task

Re: cron job

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
評比平均分數:Useful (1)
In reply to Eman Ibrahim

Re: cron job [SOLVED]

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 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.
In reply to Visvanath Ratnaweera

Re: cron job [SOLVED]

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.

In reply to Eman Ibrahim

Re: cron job

Ken Task發表於
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