Running Cron in Blue Host

Running Cron in Blue Host

by Tiffany Morgan -
Number of replies: 44

Hi all

Installed 2.5.1 in Blue Host environment. Used the CPanel to start a cron and used the instructions here: http://docs.moodle.org/20/en/Cron_with_web_hosting_services

I changed the script to:

wget -q -O /dev/null http://mysite.com/public_html/courses/admin/cron.php

I went to the server files to determine the path to cron.php (though there was also other locations for cron.php)

I am not getting a notification email and the notification page also says that a cron script has not run in 24 hours. I'm guessing there is something more I need to change, but I'm not really sure what.

Any advice would be greatly appriciated smile

Average of ratings: -
In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Stuart Mealor -

Hi Tiffany

The first thing to check (which I think is in the documentation) is if you can trigger the Cron job from the browser.  Basically you are just using a URL to check if the Cron job is able to run.

If you can, you will see the various modules being processed, backups, emails etc.

If this works OK, you might want to check the Blue Host documentation / support for Cron (sorry I don't know Blue Host)

Stu

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

I would start by modifying the line so it starts with "/usr/bin/", like so:

/usr/bin/wget -q -O /dev/null http://mysite.com/public_html/courses/admin/cron.php

This is because php is usually under /usr/bin (you may want to send a ticket to the Bluehost support department and ask about the location of php).

Also, make sure that the installation is not restricting to only executing cron via command-line:

http://docs.moodle.org/25/en/Cron_settings

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I am not a cron expert at all, but here's how I am doing it on my Bluehost account for Moodle 2.5.1+, and it works!

 

Attachment Cron Bluehost.jpg
In reply to Rick Jerz

Re: Running Cron in Blue Host

by Tiffany Morgan -

Thanks for all of the help! I didnt think to try the browser run until this morning. When I did that ran as expected- ran successfully and generated a backup email notification and the notification page on the site removed the notice that the cron had not run in more than 24 hours. I verified that the setting to run only at command line was not set. 

I modified the cron command within bluehost to

/usr/bin/wget -q -O http://mysite.com/public_html/courses/admin/cron.php

 

I set the backup to run in the last few minutes. So far no backup email notification has been received so I'm guessing Ive either done something wrong or I need to be more patient smile

I did a search locate the cron.php file and actually found it in four locations (is that to be expected and if so I assume I am directing my command to the correct place?)

public_html/courses/admin/cron.php

public_html/courses/admin/cli/cron.php

public_html/courses/admin/completion/cron.php

public_html/courses/admin/badges/cron.php

Looking like my next step is contacting the host service for assistance...

Thanks again everyone!

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

Careful there! Your command line is missing the output file (dash dev dash null):

/usr/bin/wget -q -O /dev/null http://mysite.com/public_html/courses/admin/cron.php

 

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Guillermo, thanks for this bit of education.  My cron job on Bluehost is:

/usr/bin/wget -O - -q "http://xxx04.com/moodle/admin/cron.php" > /dev/null 2>&1, which seems to work fine.

Am I including some parameters that are not needed, or do I not need the ">"?

I know that in UNIX, there may be many ways to accomplish the same task.  I am always trying to learn new techniques.

It has been awhile since I have used this form of the cron task.  Quite honestly, I am not sure where I got this.  I think that I found it over five years ago.

Thanks.

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Rick,

LOL, yes, we sometimes get code from who knows where, and if it works we just forget about it and go on! smile

Well, your command script is Ok.

The "-O -" part says, send the results, or output, to stdout (standard output: the console or screen), instead of to a file (e.g. -O somefilename).

The "> /dev/null" part at the end catches whatever is being sent to stdout and then redirects it to the null device (a black hole smile)

Finally, the "2>&1" part redirects stderr (standard error, or the error stream) to stdout, but as stdout is already redirected to the null dev, then the error stream gets discarded too.

Character ">" means start with a new file (output) and ">>" means append to the existing file.

The numbers, 0, 1 and 2 are file descriptors that mean:

0 = stdin
1 = stdout
2 = stderr

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Okay, I think that I understand.  I am redirecting the output essentially, nowhere, so I could probably just leave off the 2>&1. Or maybe I really should redirect the output to a file, using the append form of the redirect.

I am going to study these posts a little more, and try a few experiments on my experimental hosts.

Would this work?  No quotes ("s) arount the http://...

wget -q -O /dev/null http://myweb.com/moodle/admin/cron.php

Thanks.

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Guillermo Madero -

Hello Rick,

You're welcome.

You could also write:

usr/bin/wget -O /dev/null -q "http://xxx04.com/moodle/admin/cron.php"

and send the output directly to the null device. However, your original line is more complete.

Yes, you could write the line without the quotes.

Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Ack you are right! Thanks for the catch. I had been getting output emails saying every 30 minutes (as my cron was set to run every 30 minutes):

wget: missing URL
Usage: wget [OPTION]... [URL]...

Since I changed this per your catch the output emails had stopped, but on the notifications page it still says the last time the cron was run was yesterday at the time that I ran it from the browser. Does that suggest I am not pointing to the right location for the cron file?

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

Ouch! That means that my message came a bit late and the cron.php script was erased (the script was overwritten when the output of the script was sent to the script itself sad).

This can be easily fixed.

Open your Moodle installation package, extract the cron.php file under moodle/admin and save it in your-moodle-path/admin.

Cheers!

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Thanks again for your help Guillermo--much appreciated

I'm afraid I dont 100% understand what I need to do, but let me take a stab at it smile

I went to mysite.com/public_html/courses/admin/cron.php which is the path I used the first time I used the incorrect script. I downloaded that file. I opened it and everything looked original (though I don't have the original to compare). I'm not quite sure what you mean about saving it to your moodle path/admin since that is where I is already?

I also checked mysite.com/courses/admin/cron.html and that file had <?php at the top of the file, where as the other did not.

Thanks again--starting to think I'm out of my league here mixed

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

Let's start from the beginning.

Did you do the Moodle installation?

If you did, how did you upload the Moodle code (or the Moodle installation package) into your server? Did you use an FTP program (e.g. FileZilla) or you used the File Manager from your control panel.

How did you download the script cron.php?

Are you sure it was cron.html the file that had the starting "<?php" line, and not the cron.php file?

So it seems that wget avoids the problem of not having an explicit output file and instead of overwriting the php file it continued and created the cron.html file. The cron.html should then contain the output from the cron script.

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Blue host offers a one click install so I did that. 

To download the cron file I went to the file manager, drilled down to the cron.php file, selected the checkmark next to it and clicked download. Then I opened it in a text file.

It was the cron.php file that had the "?php" just verified that again. I did a search of the site for cron.html but did not have any results.I attached a screen grab of what I am seeing there

 

So far I have tried the following: 

attempt #1

/usr/bin/wget -q -O http://mysite.com/public_html/courses/admin/cron.php result: not running and generated error message via email: wget: missing URL Usage: wget [OPTION]... [URL]...

attempt 2 (7:18pm 9/25)

/usr/bin/wget -q -O /dev/null http://mysite.com/public_html/courses/admin/cron.php result: error emails stopped, still not running

 

attempt #3 (7:37pm 9/26)

/usr/bin/wget -q -O /dev/null http://mysite.com/public_html/courses/admin/cli/cron.php

result: no change, cron not run

attempt #4 6:58pm /usr/bin/wget -q -O /dev/null http://mysite.com/courses/admin/cli/cron.php

result: no change, cron not run

attempt #5 9:09pm /usr/bin/wget -q -O /dev/null http://mysite.com/courses/admin/cron.php result: waiting for half hour

 

Also, I ran the cron again from the browser just to see if it would work and it did work. That command was using  http://mysite.com/courses/admin/cron.php?password=

Thanks again!!

Attachment cron.png
In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

Oh my! I just saw it... I must be tired... you are mixing two different addresses, so to speak.

Don't put it here if you don't want or need to, but take the URL of your Moodle installation, the address you type when you visit your Moodle site. I'll assume something like http://yoursite.com/courses/

Now just add the "admin/cron.php" at the end, like so:

http://yoursite.com/courses/admin.cron.php

And finally that's the URL you should put in the wget line.

Please start with the following line (using your correct URL), you should get an email.

/usr/bin/wget http://mysite.com/courses/admin/cron.php

Once you confirm everything is ok, then just edit it like so:

/usr/bin/wget -O - -q "http://mysite.com/courses/admin/cron.php" > /dev/null 2>&1

 

Cheers!

---

The "public_html" is part of the path to the Moodle directory in the server filesystem, and so it is not part of the URL.

Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

So I had some success! When I put in 

/usr/bin/wget http://mysite.com/courses/admin/cron.php

 I got the email saying everything was ok (hurrah!)

Then I changed it to

/usr/bin/wget -O - -q "http://mysite.com/courses/admin/cron.php" > /dev/null 2>&1

 And no email after that...

Also I noticed as well that on my notifications page it still says the last time the cron was run was the time I ran it manually. 

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

Yes, that precisely was the idea, that you first received an email so you could see and confirm that everything was now working as it should. Once confirmed, no more emails. Do yo really want to receive an email each and every time cron runs?

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Tiffany, what I like to do is to create a forum in a test course, make one post, and then watch to see if, and when it arrives.  Make sure that you are "in" the course in some role (student, teachers, manager, etc.)

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Tiffany Morgan -

THanks all--

No dont what an email each time the cron runs, but was worried that I had set something wrong if I wasn't getting an email.

The email notification I was receiving was:

--2013-09-27 19:00:02-- http://mysite.com/courses/admin/cron.php Resolving mysite.com... 6x.8x.2x.1xx
Connecting to mysite.com|6x.8x.2x.1xx|:80... connected.
HTTP request sent, awaiting response... 200
OK Length: unspecified [text/html]
Saving to: `cron.php.1' 0K 6.82M=0s 2013-09-27 19:00:10 (6.82 MB/s) - `cron.php.1' saved [74]

This made me think everything was working ok, but I set up a test course, added a dummy user with a valid email address. Made a forum post and marked it as email now. No email. Also I notice that on the notifications page it still says that the cron has not been run in more than 24 hours. So even though I had been getting the emails saying the script was running, it still says it has not been run on the notification screen. Ran the manual cron again-emails pushed through and notification changed to when it was run. 

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

One of the dangers of NOT getting EMails on a regular basis is you won't know if it's really working or not.   So ... don't use your regularly used EMail address!  Should be able to setup another addy for your domain ... make that one 'moodleadm@yourdomain.x' and set Moodle to use that addy for administrative stuff.

OR create a rule in whatever use use for mail to route any incoming message whose subject line contains 'Cron blah, blah' to go to a moodlecron folder (don't forget to check it from time to time)

The dev/null and other redirect is an attempt to prevent email from being sent - actually it attempts to redirect the output off into a blackhole.

If you look at the page for Cron in Moodle.org
http://docs.moodle.org/24/en/Cron_with_UNIX

wget is a web getter … to acquire files.  Your latest shows it did work in that a cron.php.1 file was created and is what would have been displayed had you run the cron command another way.
This will build up … the next running will create a cron.php.2 file, then a .3, then a .4, etc.
Those files may not be cleaned up by the system as they are not really logs which are rotated.
Over a looooooong period of time one may run out of space due to all the cron.php.# files.

Also you can see the message was 6.2 Megs in size … larger cron.php.# files usually indicates autobackups is turned on.

In the link above it shows another way to use php by itself - command line php.

/usr/bin/php -f /path/to/moodle/admin/cli/cron.php

There is a switch to php: -f which tells php that it is supposed to work with a file - parse and execute.

So suggest, the poster here WANTS to get email.  Drop the redirects AND point to the cron.php script that is restricted to command line only at moodlecode/admin/cli/cron.php

/usr/bin/php - might have to be pointed to the version of PHP desired … version 5.  On some remotely hosted systems they offer 2 php versions.  /usr/bin/php might be version 4 of php on some remotely hosted systems.
Version 5 is in /usr/bin/php5/php … on some remotely hosted systems.  Check with hosting provider.

The only other problem for remotely hosted systems is to discover the full path the moodle/admin/cli/cron.php file.  The path to Moodledata is close.

It might be /home/customers/customerIDnumber/public_html/moodle/admin/cli/cron.php

So … an example:

/usr/bin/php5/php -f /home/customers/customerIDnumber/public_html/moodle/admin/cli/cron.php

If the remote provider has a tool to run the cron job, run it via their system.  Using the web based cron.php script is NOT the same setup.

Providers also have some policies concerning EMail distribution ... wonder if Bluehost has such restrictions.  Check with provider.

Truth in assisting ... don't host on Bluehost, but in Googling see they do provide customer pages related to running crons.   Those pages, however, don't mention redirects ... at least I didn't find any.

'spirit of sharing', Ken

In reply to Ken Task

Re: Running Cron in Blue Host

by Guillermo Madero -

"Dangers"? Quite a strong word, I'd say smile I usually set up my cron jobs, confirm that they are working Ok and then send their output to nowhere. Once in a while I check through the browser that everything is Ok, and usually is. Anyway, there are many options, sending to null, to an email address or appending to an output log file.

Indeed, wget is a web getter, used to download web pages and so, but what happens when you access a php file? You don't get the php code, it gets executed, and that's why using wget works. There is actually nothing wrong with using wget, but then again, there are many options: wget, php, lynx, curl. To each his own.

Right, the length of the resulting file indicates a very long report caused by the automated backup process.

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

To each is his/her own, but ... wget launches an apache process which calls php to run cron.php = more processing.   It also relies on virtual apaches and DNS functioning (shared system) ... you can see that in the output of what was posted.  Php is already on the server ... no DNS checks ... no apache process launched ... and if pointed to the cli version more efficient server wise.

Considering the 'bloat' of 2.5 (ie, heavier processing - does more) and that fact that shared hosting is probably barely enough to run a few courses, I'd seek what ever is less but gets the job done.

Of course ... my 2 cents.

'spirit of sharing', Ken

In reply to Ken Task

Re: Running Cron in Blue Host

by Guillermo Madero -

I agree on the bloat of 2.5 but I must confess that I don't see in that report everything that you mentioned smile

Maybe PHP is running as a module or maybe as FastCGI, I don't know.

Anyway, yes, php would be a better option, but I don't think that the problem resides on the command being used (wget, curl, php). So I'd say that OP needs to have everything running before starting to consider possible optimizations.

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

wget produces two different outputs:

1. a log about what it did

2. the output from what it did (in this case, the output of cron.php)

When an output file isn't specified, wget creates one based on the name of the file being called (i.e. cron.php), so that is why a cron.php.1 file appeared.

If you follow the -O (upper case letter "o") option with a file name (-O somefilename), this file will be overwritten every time wget runs.

Well, please rewrite your cron job command like so (with your own, correct URL, of course):

/usr/bin/wget -a cron-log.txt -O - http://mysite.com/courses/admin/cron.php >> cron-out.txt

This will create a log file (cron-log.txt) and an output file (cron-out.txt) for you to check. Neither will be overwritten, as both log & normal output will be appended to each.

If you are actually calling the cron.php script with a correct URL in your cron job, I can't see why it would say it hasn't run. Anyway, the last message seems to indicate that it is running fine.

Maybe cron is running fine and you only need to check about the email settings in your Moodle installation.

http://docs.moodle.org/25/en/Messaging_settings

---

https://my.bluehost.com/cgi/help/cron
https://my.bluehost.com/cgi/help/411
https://my.bluehost.com/cgi/help/168

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

FWIT ...
https://my.bluehost.com/cgi/help/168
a quote ...
Custom Installations without Easy Apache 3 (VPS/Dedicated)
PHP

Command to run for a PHP5 cron job:
/usr/local/php5/bin/php5 /home/username/public_html/cron.php

The path to the OP's Moodle code would have to replace the example above.  Something near/like:

/home/username/public_html/[courses?]/admin/cli/cron.php

A Note: on the page linked above says using /usr/bin/php uses PHP4.  So what package does the OP have with Bluehost?

'spirit of sharing', Ken

In reply to Ken Task

Re: Running Cron in Blue Host

by Tiffany Morgan -

wow--lots of help here! Thanks to all

I have php5

I tried:

/usr/bin/wget -a cron-log.txt -O - http://mysite.com/courses/admin/cron.php >> cron-out.txt

result: It did output a text file but when I tried to open it it said: 

!!! Sorry, you have not provided a valid password to access this page !!!

I checked the logs and it all seems to be running as it should. I checked the notifications page-still shows the last run as when I did it manually. 

 

Next try was:

 /usr/bin/wget /home3/username/public_html/courses/admin/cli/cron.php

This resulted in an email being sent with the following: /home3/username/public_html/courses/admin/cli/cron.php: Scheme missing.

Still no change on the notifications page

 

Next try was:

/usr/bin/php -f /home3/username/public_html/courses/admin/cli/cron.php

Result: Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version 5.2.17). Some servers may have multiple PHP versions installed, are you using the correct executable?

But When I check the site info it shows that Im have 5.3.27 installed. So I'm guessing that means I'm pointing to the wrong file. 

 

I feel like all of this is an issue of me pointing to the wrong place with the wrong script, but I'm unclear as to how to determine which is the right file. I searched the entire site for cron.php with the following results:

 /cron.php
/public_html/courses/admin/cron.php
/public_html/courses/admin/cli/cron.php
/public_html/courses/completion/cron.php
/public_html/courses/badges/cron.php

...I think I'm out of places to point it to

Thanks again everyone--you guys are awesome smile

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Tiffany Morgan -

I realized I misread to and had used the path for php4. I used the path for php5

/usr/local/php5/bin/php5 /home3/username/public_html/courses/admin/cli/cron.php

Result was: /bin/sh: usr/bin/php: No such file or directory

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

Hi Tiffany,

As I mentioned, the command line should have created two text files: cron-log.txt & cron-out.txt. Which one did you open? Wasn't there another one?

Did you actually read the documentation page (and related pages) I originally sent you? Please tell me you read it (them).

http://docs.moodle.org/25/en/Cron_settings

http://docs.moodle.org/25/en/Cron_with_web_hosting_services
http://docs.moodle.org/25/en/Cron_with_UNIX

At the beginning of the Cron settings page it shows that the cron script, when run from a browser, can be protected with a password.

If the file you opened said something about needing a password then it seems that a password has been set (Administration >Security > Site Policies) and that would explain why the notification page says what it says.

You actually needn't be doing all those "trial & error" tests. Once again, the documentation pages explain that there are two ways to run cron.php, a web based one (wget with an URL) and a command line based one (php with a file path).

wget http://somsite.com/moodle/admin/cron.php

php /some/long/path/moodle/admin/cli/cron.php

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Hi Guillermo

It did create two files. I was able to open and review cron-log.txt when I opened cron-out.txt it said

!!! Sorry, you have not provided a valid password to access this page !!!

 I had previously reviewed http://docs.moodle.org/25/en/Cron_settings and the cron execution at command line is set to default of no. I have a password set for remote access

 

I had reviewed http://docs.moodle.org/25/en/Cron_with_web_hosting_services

Based on the first suggestion on that page I tried running the wget
wget -q -O /dev/null http://mysite.com/public_html/admin/cron.php
Result: cron did not run

Then I tried what I thought was running from the command line
/usr/local/bin/php -q home/username/public_html/admin/cron.php
result: /bin/sh: /usr/local/bin/php: No such file or directory

Based on http://docs.moodle.org/25/en/Cron_with_UNIX I tried:  
/usr/local/bin/php -q http://mysite.com/public_html/admin/cli/cron.php
result: /bin/sh: /usr/local/bin/php: No such file or directory

 

I agree one of these should just work. After two hours with blue host and confirmation that I have the correct version of php, so Im clearly missing something in my own understanding to make this happen. 

Thanks for the help you provided. 

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, will interject one more time ... and then it's all G! ;)

"Based on the first suggestion on that page I tried running the wget
wget -q -O /dev/null http://mysite.com/public_html/admin/cron.php
Result: cron did not run"

Cron did not run or it just didn't display anything?

the -O /dev/null means send output to nowhere - not to a file but null … blown to data bits … display nada … display nothing!

The -q means quiet - turn off wget's output.

Have you tried without the switches (-q and -O /dev/null):

wget http://mysite.com/admin/cron.php

Notice there is no public_html in the above URL.  It is the same URL to your site if you were using a browser http://mysite.com/ only adding admin/cron.php

Apache serves out anything in public_html.  That's what is called 'document root' on your system.

The examples on the moodle docs page are just that … examples … NOT to be used literally without checking for things like the path to PHP5 on your system.

So /usr/local/bin/php doesn't exist on your Bluehost system.
That's what the result:  /bin/sh: /usr/local/bin/php: No such file or directory was telling you.  It couldn't find php at /usr/local/bin/

In the page BlueHost provide it said to use:
php with *no* path.  Thus:
php /home/username/public_html/admin/cli/cron.php

and that would automagically run php version 5.x
The Bluehost page also said if you used /usr/bin/php that would call up PHP version 4 … NOT 5 … and that won't work.

It appears Bluehost has different ways according to the package offered and purchased by the user.  Suggest contacting Bluehost again and telling them you want to run the cron.php file @ /home/username/public_html/courses/admin/cron.php.

Ok, G!  outta here! ;)

'spirit of sharing', Ken

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Guillermo Madero -

So you:

have a password set for remote access

and the cron-out.txt file says:

!!! Sorry, you have not provided a valid password to access this page !!!

But you haven't, at any time, mentioned anything about including the password in you cron command, as indicated in:

http://docs.moodle.org/25/en/Cron_settings

Please retry now with:

/usr/bin/wget -a cron-log.txt -O - http://mysite.com/courses/admin/cron.php?password=your-password >> cron-out.txt

 

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Thanks again all. I really do read all the links posted and do my best to understand and follow the instructions as I understand them. If I failed to change something necessary and specific to my installation it was because I did not correctly understand which parts must be entered as is and which parts needed to be changed for my install.
To answer your first question Ken: I understand the -q to meant send the output to nowhere. When I ran get -q -O /dev/null http://mysite.com/public_html/admin/cron.php Cron did not run. I base that belief on 1) the notifications not changing within moodle showing the script had not run in more than 24 hours and 2)no emails being sent via moodle saying cron based actions were done (ie backups made, forum post emails sent etc). When I do run the cron via a browser both of those things happen so I when they dont I assume cron to be unsuccessful. If there is another way to determine if it is running I am not aware of that.

I tried wget http://mysite.com/admin/cron.php the result was that it seems to have not run, again based on the 1) the notifications not changing within moodle showing the script had not run in more than 24 hours and 2)no emails being sent via moodle saying cron based actions were done (ie backups made, forum post emails sent etc). Also I received a notification from the server
--2013-10-01 20:20:02-- http://mysite.com/admin/cron.php Resolving mysite.com... xx.xx.xx.xx Connecting to mysite.com|xx.xx.xx.xx|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2013-10-01 20:20:02 ERROR 404: Not Found.

I did have a password but I have now removed that. I read the documentation but did not understand that having the password there necessitated adding it to the cron script so I apologize. I contacted blue host again.
I told them: I need to run php version 5 and to run the cron.php file at /home/username/public_html/courses/admin/cli/ via a command line. When I ran /usr/local/php5/bin/php5 /home3/username/public_html/courses/admin/cli/cron.php it resulted in: in/sh: /usr/local/php5/bin/php5: No such file or directory
The chat host had me run php home3/username/public_html/courses/admin/cli/cron.php which I did. It resulted in bin/sh: /usr/local/php5/bin/php5: No such file or directory
The blue host chat support had me change the php settings to php5.3 single php.ini which I did. I ran php /home3/username/public_html/courses/admin/cli/cron.php it resulted in: Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version 5.2.17). Some servers may have multiple PHP versions installed, are you using the correct executable?
The host chat then said it was working through SSH and I should file a support ticket, which I did, but they have said they do not support user entered cron jobs. So apparently no support there.
--
I did try running /usr/bin/wget -a cron-log.txt -O - http://mysite.com/courses/admin/cron.php>>; cron-out.txt (without the password portion as I have now removed the password while testing).
This resulted in two files: cron-out.txt and cron-long.txt.
cron-log.txt had: 2013-10-01 18:10:06 (1.85 KB/s) - written to stdout [4091] --2013-10-01 18:11:01-- http://mysite.com/courses/admin/cron.php Resolving site.com... xx.xx.xx.xxx Connecting to site.com|xx.xx.xx.xxx|:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/plain] Saving to: `STDOUT'

cron-out.txt had what looked like what I would expect from a successful cron run, the last lines being: Cron script completed correctly Cron completed at 20:03:03. Memory used 41.9MB. Execution took 0.825844 seconds

It would seem by that that it ran, but after this was there were no emails were sent by the moodle system to dummy students , backup notifications not sent, etc (that had been sent before on the ssh run and by a browser run). But again, if there is a better way to confirm it is running I would gladly check that.

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

'The host chat then said it was working through SSH and I should file a support ticket, which I did, but they have said they do not support user entered cron jobs. So apparently no support there.'

Many hosting providers have restrictions related to the sending of EMail especially if customer is on a shared host. Last thing they want is a customer who is trying to become the 'spam king'. That would affect all customers on the shared system.

"no emails were sent by the moodle system to dummy students , backup notifications not sent"

The dummy students have valid EMail addresses? Addresses to which EMail could be delivered?

'chat host' *may* have said:

php /home3/username/public_html/courses/admin/cli/cron.php

Missing in your command the first '/' and you are replacing 'username' above with the account name that has been assigned to you, correct?
'username' is a place holder/variable to be replaced with the customers username.

wget -q -O /dev/null http://mysite.com/public_html/admin/cron.php

Should be:

wget -q -O /dev/null http://mysite.com/courses/admin/cron.php

IF your Moodle is located in a folder called 'courses'. If the Moodle code is in 'public_html' then it should be:

wget -q -O /dev/null http://mysite.com/admin/cron.php

If you get

"Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version 5.2.17)"

It means they have pointed you to a 5.2.17 version of PHP and Moodle 2.5 requires minimum of 5.3.3. Did you inform them?

The running of cron does work … this is really NOT a Moodle issue at all, but a hosting provider issue in support of customers.

'spirit of sharing', Ken

 

Average of ratings: Useful (2)
In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Tiffany, just so that you know, in my Bluehost, I went to cPanel and picked PHP 5.4 from the menu.  I did this before I installed Moodle 2.5, but I really don't know if this matters.  I see that cPanel really installed PHP 5.4.20, which exceeds the current Moodle PHP requirements.  I have no idea at all about whether the PHP version affect the cron job.

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Ken Task -
Picture of Particularly helpful Moodlers

First, the only cron.php files we should be working with is the one in either courses/admin/cron.php OR courses/admin/cli/cron.php.

The first one: courses/admin/cron.php *can* be called by web browser directly or by tools like wget or curl.

The second one: courses/admin/cli/cron.php can be called ONLY by command line - with the correct path to php version 5.

According to their documentation - which appears to conflict itself:

https://my.bluehost.com/cgi/help/168

In one section it says ...

PHP

Command to run a PHP5 cron job:

php /home/username/public_html/cron.php
 
In your case:
php /home/username/public_html/courses/admin/cron.php
 
In a section at the bottom of the page is says:

Custom Installations without Easy Apache 3 (VPS/Dedicated)

PHP

Command to run for a PHP5 cron job:

/usr/local/php5/bin/php5 /home/username/public_html/cron.php
 
Using your path:
/usr/local/php5/bin/php5 /home/username/public_html/courses/admin/cli/cron.php
 
What package did you purchase from them?

And one more tip: wget has to use a URL not a path.  If you have a password on running cron, you must provide the password:

wget http://yoursiteURL/courses/admin/cron.php?password=[password]

where [password] IS the password you've given the config of Moodle to use.

The docs don't mention it, but wonder if BlueHost provides curl.

Suggest contacting Bluehost and 1) telling them you need to run php version 5 and 2) you want to run the cron.php file at /home/username/public_html/courses/admin/cli/ via a command line method.

'spirit of sharing', Ken

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Tiffany, you have been getting some great advice from the other folks, but somehow, it seems to me that this is becoming more difficult than it should be.  I just tested my Bluehost Moodle 2.5.1+ install, and it is sending out emails.  I didn't really have to do much, either.  If it makes sense to you, let's start again with some simple information.

1) You have a standard Bluehost hosted server account, right?

2) Exactly, how did you install Moodle?  Did you use the one button install, or did you install it yourself from scratch?

3) Do you really not have a "moodle" folder?  Did you really tell moodle during it's install that you did not want the default "moodle" folder, and used "courses" instead?

4) Have you asked Bluehost why your emails are not working?  I think that Bluehost claims to know something about Moodle.  They might have a simple solution for you.

After I got my (free) Bluehost account, I was able to get Moodle up an running, including cron, in less than 30 minutes.  So I am puzzled why you are struggling with these cron entries.  (By the way, the one that I posted to you is what I am using right now, and it works.)

I really appreciate the extra knowledge of Ken and Guillermo, they are really great.  I am learning a lot just by following this discussion.

Maybe I can make a video showing how I installed my Moodle on Bluehost, but I need to know the answers to the above questions.

Below is a screen shot showing that I really did get an email.  My cron job is set to run every hour at 38 minutes.

Attachment email.jpg
In reply to Rick Jerz

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I looked at some of this discussion again, and saw some answers to my questions.  Sorry about that.

1) Yes, you have a hosted server account.
2) You used a one-click install
3) I don't know your answer to this
4) You have had various chats with Bluehost, no solution yet.

I used to use a one-click install for Moodle on a GoDaddy hosted server, and I am not a fan of these auto installers.  Sometimes, you really don't know what is going on in the background and what assumptions have been made.

Have you considered doing an install from scratch?  Maybe I can show you how.

Also, do you mind sharing the real location of your hosted account main webpage?  For example, my Bluehost website is at www.rjerz04.com.  You won't see much if you go there, so don't be surprised.

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Guillermo Madero -

LOL! Surprised? No, it looks like my own site! big grin

In reply to Guillermo Madero

Re: Running Cron in Blue Host

by Tiffany Morgan -

Hi Everyone

THanks again for the help. I had to step back and take a few days away on this smile Hopefully I can answer all the questions

Ken--completely understand why the hosting company wouldn't be able to help with the cron. Not just the spamming, but with having to know the ins and outs of every possible application a client might install, that is just not going to happen. Don't blame them for that. What I cannot understand is when I ask for help to point to the specifc version of php, they give me the code for that,  and the error message generated after doing so says it is still pointing to the wrong one, how that isn't their system? But I digress smile Yes, the dummy student had a valid email. 

I had been changing the username to the user name specific to my account, but I had not been removing public_html. The path I see in file management to locate cron.php file is public_html/courses/admin/cli/cron.php OR public_html/courses/admin/cron.php (There are two cron files--but in the documentation is sounds as if I am supposed to pointing to cli/cron.php, if I understand correctly) So given all that when I run wget -q -O /dev/null http://mysite.com/admin/cron.php I get:  Status: 404 Not Found
Content-type: text/html  No input file specified.

 

Rick--YES--this absolutely feels like way more work than it should take to accomplish this. I haven't set up a Moodle site from scratch before but have managed a site for 4 years and I have never had an issue that has taken this long to figure out. I couldn't be further from a server admin, but still I really thought I could make this happen. But again--I digress smile Do you really not have a "moodle" folder?  Did you really tell moodle during it's install that you did not want the default "moodle" folder, and used "courses" instead?   I really dont have a moodle folder. When I set up the one click install I had it do mysite.com/courses. my phpconfig says I am using php3 single php.ini. Blue Host had me change that other night.Prior to that I had 5.3 (noted in the host as: All files with the extension .php will be handled by the PHP 5.3 engine.
Most reliable and compatible version of PHP.)  When I check admin > server > php It says 5.3.27 It also says: Configuration File (php.ini) Path /usr/php/53/etc Loaded Configuration File /home3/username/public_html/php.ini

Yes, am very close to scrapping it all and starting fresh. I have only one test course and a handful of dummy users so it wouldn't be a huge loss. 

The real location is http://k9handleracademy.com Full functioning site live site ( though I do not manage  that portion) 

Thank again everyone 

 

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I too have been away for awhile.  And right now, I am working on a brand new class that begins next week.

Okay, I see your website and I see your Moodle.  This one-button install is a little unconventional, not to say it shouldn't work, its just a little different.

I would like to help you with some videos, but I am tied up right now and probably won't be able to get to this until the weekend.

I'll ask another question: Do you know how to use SSH?  I ask this because my own technique for doing an install of moodle is easiest if you know SSH, and also have an FTP client.

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Tiffany Morgan -

If you had time and wanted to do that I wouldnt say no! smile 

I too have been a way from it awhile--mostly so I wouldnt throw my computer through the wall smile One oddity that came up that I am going to explore this weekend with BlueHost is: when I walked away I removed all of the cron commands I had put in. So no cron listed in my cron settings. 3 days later--cron ran, backups made, updates for my version of moodle checked for, emails to dummy students sent out, notification page removes the "cron hasn't run in more than 24 hours" notice. Everything you would expect from a successful cron. So there is something going on the server side that I dont have access to that I have a feeling is impacting all of this. 

Thanks again smile

In reply to Tiffany Morgan

Re: Running Cron in Blue Host

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Wow, so you went to cPanel, CRON, removed all jobs, and it is now working!

If you now make posts with your "dummy" students, do they get sent?

In reply to Rick Jerz

Re: Running Cron in Blue Host

by Tiffany Morgan -

3 months later I FINALLY returned to this task. I uninstalled Moodle, reinstalled, used the cron instructions referred previously (https://moodle.org/mod/forum/discuss.php?d=239441#p1042347) and it worked perfectly on the first try! I wonder if something went wrong with the install or the many incorrect crons I ran, but either way it is working now. I once again thank you all for your help and patience! You all rock smile