I have a script that's scheduled to run periodically on a customers production server to import some data from their FTP server. This needs to run as scheduled, even during the day when the customer is working. Occasionally, the script takes up large amounts of CPU which slows down the customers production environment. I thought I could use cpulimit to control the process, but I can't seem to get it to run properly from within PHP. I have a sandbox script with the following lines:
$pid = getmypid();
exec("/usr/bin/cpulimit -p $pid -l 20 -z < /dev/null 2>&1 > /dev/null &");
When I get the pid and run this exact command from the command line it works great. However, when I run the script I get [1]+ Stopped php web/sandbox/sandbox.php
. I have run background tasks from PHP scripts exactly like this many times. What could I be doing wrong?
Thanks in advance,
~ JamesArmes