Cron Job on Siteground

Cron Job on Siteground

написао/ла Susan Carmichael -
Број одговора: 7

Hi, can anyone please help me?

I am trying to add a cron job on my Siteground server for Moodle and I need help. I believe have identified the correct path to the script, but I am unsure what to put in first (before it) in the command field (e.g. /usr/local/bin/ea-php7.3). This is what I'm trying (amongst other things) but so far, nothing has worked. Can anyone please help me?

У одговору на Susan Carmichael

Re: Cron Job on Siteground

написао/ла Rick Jerz -
Слика Particularly helpful Moodlers Слика Testers
A screenshot or two of what you are trying to do could help.
У одговору на Rick Jerz

Re: Cron Job on Siteground

написао/ла Susan Carmichael -
Hi, thanks for getting back to me.

I attach a screenshot showing the current command line, which was suggested by a chat support operative at Siteground after a lengthy chat. I would really appreciate any ideas you may have. Many thanks!
Прилог Screen Shot 2020-11-16 at 09.31.58.png
У одговору на Susan Carmichael

Re: Cron Job on Siteground

написао/ла Ken Task -
Слика Particularly helpful Moodlers

SiteGround hosting is a different beast now that it's backended on Google so docs for Moodle might still apply but with consideration of the 'special things' Google might be doing.

I happen to have a Google Compute Engine instance of CentOS 7 and moodle.   Can say that for most things Moodle docs apply.

In your case, with SiteGround, close but ...

Anyhoo ...

https://www.siteground.com/tutorials/cpanel/cpanel/cron-jobs/

While below is about Magento ... hopefully, same applies for Moodle

https://community.magento.com/t5/Magento-2-x-Hosting-Performance/Configuring-cron-job-for-siteground/td-p/37319

If your hosting provider uses cPanel, you should be able to use the following Cron Job:-

SiteGround doesn't use cPanel but a panel of it's own.  Hopefully, they are similar enough ...

For Moodle code located in public_html:
php /home/<CPANEL USERNAME>/public_html/admin/cli/cron.php

You, Susan, would replace the <cpanel username> above with yours.

Warning!   Don't host with SiteGround myself ... so above is really a guess!

'SoS', Ken

У одговору на Susan Carmichael

Re: Cron Job on Siteground

написао/ла Ken Task -
Слика Particularly helpful Moodlers
У одговору на Ken Task

Re: Cron Job on Siteground

написао/ла Susan Carmichael -
Hi, thanks for getting back to me. Yes, I have tried everything I can see there without success. I believe the problem I'm having is that the command line is not correct, but No-one at Moodle or Siteground can tell me what it should be. I understand there are are two parts to the command. Moodle seems to suggest several variations of the first part of the command, all of which I have tried. The path to the script itself, which is the original script, in the original directory location on the Siteground server should be correct, but no-one seems able to confirm that it should work. Each variation of the command line I have tried so far has failed to alter the message in Notifications saying "The cli/cron.php maintenance script has not been run for at least 24 hours". Also, the notification emails which come in thick and fast (the cron interval is set at 1 minute) all suggest the file path is incorrect (here is one from one of the previous attempts, they have all been similar):

/bin/sh: /usr/local/bin/ea-php7.3: No such file or directory

I attach a screenshot showing the current command line, which was suggested by a chat support operative at Siteground after a lengthy chat. I would really appreciate any ideas you may have. Many thanks!
Прилог Screen Shot 2020-11-16 at 09.31.58.png
У одговору на Susan Carmichael

Re: Cron Job on Siteground

написао/ла Rick Jerz -
Слика Particularly helpful Moodlers Слика Testers
Well, this is what Siteguard has told you, and it doesn't work. I am not sure, but Ken will probably have some additional good thoughts.

I have used two forms of cron. My current one looks like this:
/usr/bin/php /home/username/public_html/moodle/admin/cli/cron.php > /dev/null

My former one looks like this:
/usr/bin/wget -O - -q "http://yourdomain.com/moodle/admin/cron.php" > /dev/null 2>&1

The second one looks more like yours, but you might try both and see if either might work. There are two things that are important: 1) the location of either wget or PHP. 2) the location of your cron.php file.
У одговору на Susan Carmichael

Re: Cron Job on Siteground

написао/ла Ken Task -
Слика Particularly helpful Moodlers

If using wget (which is really a text based web page 'getter' and according to one of the main developers of Moodle is supposed to be 'depreciated'), one has to use a **url** site not path.

https://onlinelearning.sassystirrers.com/admin/cron.php

can't use the one in /cli/ as that is for command line only execution.

Really best to find php-cli for version of PHP desired and execute thusly:

/path/to/ea-php73/bin/php /full/path/to/account/public_html/admin/cli/php.cron

Above may be in-correct as to directory for ea-php73 as I don't host on SiteGround ... educated guess?!!

Easy Apache allow you to choose which version of PHP to run and each version of PHP is some directory ... **like** (example ... do NOT copy and paste):

/usr/bin/eaphp71/

/usr/bin/eaphp72/

/usr/bin/eaphp73/

php-cli might be in a bin directory above.

Guess: /usr/bin/eaphp73/bin/

php-cli is command line ... and the way to discover which php-cli to use in cron job, normally done via ssh into account and issuing:

which php [enter]

That command **might** respond thusly:

/usr/bin/php

But that might be the lowest version of PHP on system and not the desired version.    To find out, use full path as shown above and check version:

/usr/bin/php -v

Response from that will show showing like:

PHP 7.2.34 (cli) (built: Oct  1 2020 13:37:37) ( NTS )

Note it shows the version and that it's the cli (cli) above.

Surprised SiteGround help desk cannot assist with this.  You might need to ask them what is the full path to easy apache version desired and the location of php-cli (command line executable)

Login to the moodle and go to site Admin Server PHP info.

In a line for Response headers one should see X-Powered and the version of your Easy Apache.

Other clues as to location ... paths to php.ini being used ... and scan this directory path.

'SoS', Ken