My cron job was running very slowly so I looked at the "Running Processes" and see that although I only have 8 processes running, the auto_cb_update.php is only getting 2.9 % of the processor to use so is consequently running very slow.
I have run this job many times before and it usually gets between 30 and 70 %
The process usually takes 4 minutes, it has been running for 15 mins already and not finished :(
Any idea what the reason for this might be ?
This is what is running:
31458 guru54gt5 2.9 % php -q /home/guru54gt5/public_html/sys/auto_cb_update.php
32083 root 1.6 % /usr/bin/python -tt /usr/libexec/yum-updatesd-helper --check --dbus
23479 mysql 0.8 % /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql -user=mysql --pid-f ...
32143 root 0.3 % /usr/libexec/webmin/proc/index_cpu.cgi
30026 fethiye-guide 0.1 % /usr/bin/php-cgi
30027 fethiye-guide 0.1 % /usr/bin/php-cgi
30028 fethiye-guide 0.1 % /usr/bin/php-cgi
30029 fethiye-guide 0.1 % /usr/bin/php-cgi
1 root 0.0 % init [3]
2 root 0.0 % [migration/0]
3 root 0.0 % [ksoftirqd/0]
everything else is 0.0 %
So total percentage is 5.9 % so what is the 94.1 % doing ?
It is going to take an hour to finish the job at this rate !
Howdy,
Well, a couple of things --
First, it's very unlikely that all the processes would ever add up to 100%. Looking in the "ps" manpage, the CPU time expressed is:
"CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process."
Second, I don't know anything at all about auto_cb_update.php, so I'm not sure what it does, or what factors could cause it to run slower. For example, it could be a bug or design in a new version of the app that was recently installed.
This is where it gets tough to diagnose... a common factor as to why it would run slower is if its waiting on something else.
That could be a lot of things --
If your server is doing more things than previously, you may be using more disk IO. And when there's less disk IO to go around, processes that require disk access take longer to run.
If that process is making use of MySQL, if there's more database entries it has to sort through than previously, that could certainly cause it to take longer to run.
If you're running all this on a VPS rather than a dedicated server, other VPS users on your same hardware may be using more CPU or disk IO, making less available to you.
With all that in mind -- does it actually matter how long it takes to run? Can you put it in to run at 2am or 3am, knowing that it'll start after you go to sleep, and be finished before you get up? :-)
-Eric
OK - thanks for your reply.
Just wanted to make sure I wasn't missing anything.
I haven't seen any priority level to set - is there such a thing?
eg priority = low|med|high|highest or 1,2,3,4,5, ??
So that you can tell the server to give most resources to a certain process rather than others.
Howdy,
You can change the priority a command runs at by preceding it with "nice".
For example, if the command running from your cron job looks like this:
php -q /home/guru54gt5/public_html/sys/auto_cb_update.php
You can precede it with a nice command such as:
nice -n N php -q /home/guru54gt5/public_html/sys/auto_cb_update.php
Where "N" is a number between -19 and 19.
Running at -19 means "highest priority", 19 means "lowest prority", and you have all the numbers in between to play with too :-)
Unless specified, I believe tasks default to "0", or medium priority.
You can read more about nice by typing "man nice" from the command line.
-Eric