cron.php leads to a very high cpu usage

cron.php leads to a very high cpu usage

hugo joe írta időpontban
Válaszok szám: 10

I set the cron in Debian as this:

*/15 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php >/dev/null
But it leads to a  very high cpu usage(96%). (ref to attachment)

When I disable the cron, all go back to normal.

Any suggestion?

Best Regards.

Hugo
top.png csatolmány
Értékelések átlaga: -
Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Emma Richardson írta időpontban
Kép Kép Kép

Cron does tend to spike the cpu but with the exception of when it is running backups, it should only take a few seconds to run.  Do you have Cron running anything else other than the Moodle scripts?

Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Emma Richardson írta időpontban
Kép Kép Kép

And forgive me the stupid question but you don't actually have path/to written in the actual cron script, right?!!

Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Frederic Nevers írta időpontban

Hi Hugo, 

my guess is automated backup that it causing the high CPU usage. Try to disable it, restart cron and see what happens.

Cheers, 
Fred

Értékelések átlaga:Useful (1)
Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Simon Story írta időpontban

You could run the cron the the foreground and see where it spending all it's time.

You can run it in the foreground by doing

$ sudo su www-data

$ /usr/bin/php /path/to/moodle/admin/cli/cron.php

Obviously replace that last bit with where your cron.php actually is..

And see what happens.

Válasz erre: Simon Story

Re: cron.php leads to a very high cpu usage

hugo joe írta időpontban

I run "/usr/bin/php /path/to/moodle/admin/cli/cron.php", it stops during "Processing module function quiz_cron ...".

Maybe is it  the problem?

cron ~_2012-07-30_12-51-18.png csatolmány
Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Visvanath Ratnaweera írta időpontban
Kép Kép
Hi

The cron.php output definitely has clues to the problem, if one could read it!

Yet another reason to paste the text into the message.
Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Floyd Saner írta időpontban

Hugo,

Emma's about the path is very important.  Use your web server browser to find the exact path to your Moodle directory.  If Moodle is installed as a subdirectory in your home directory, then you should use:

*/15 * * * * /usr/bin/php  /home/moodle/admin/cli/cron.php >/dev/null

There are other commands you can use.  If you have CPanel, search for cron and enter the following in the command line (use your real web address for Moodle). For example, if your Moodle installation is located at http://www.hugo.com/moodle then your cron command should be 

wget -q -O /dev/null http://www.hugo.com/moodle/admin/cli/cron.php

Válasz erre: Floyd Saner

Re: cron.php leads to a very high cpu usage

Paul Vaughan írta időpontban

Instead of redirecting cron's output to /dev/null, why not redirect it to (for example) /tmp/moodlecron.log ?

You'll see exactly what cron is up to. (And you won't get overrun with log files, as the file will be overwritten each time cron runs.)

Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

Andrea Bicciolo írta időpontban

Looks like cron processes run on top of each other. You could also try the following:

  • run Moodle cron CLI script from within a shell script. Before invoking Moodle cron, the shell script could check if another Moodle cron process is still running, and if yes just exit.
  • assign to Moodle cron a lower priority using nice, such as "nice /usr/bin/php ...."

I'd also follow the suggestion in the thread about keeping cron execution log, at least for a given number of runs, so it is possible to check what happened during cron processing.

Válasz erre: hugo joe

Re: cron.php leads to a very high cpu usage

hugo joe írta időpontban

ThanksIgen

I am on vication and hard to connect to server. I will check it and report the result.

Best Regards.

Hugo