%CPU at 99% when cronjob runs php script every minute – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, php, email, cron, cpu-usage.
I am using a debian server and for some reason when I run this php script using crontab every minute it says that I am using 99% of the %CPU with the php command (in the cronjob the command is php) and the emails will not send. Eventually it says I am out of memory in the tmp folder. The weird part is that for about 10 minutes the cronjob worked perfectly; it sent me the emails every minute and the CPU usage was very low which was good. After that 10 minutes though, the CPU percentage spiked to about 99% again and the emails stopped sending.
If I manually send this email using the command: “php mail1.php”, I receive the email with all the contents and there are no problems. With cronjob sending them, I can’t even receive 1 anymore. If anyone has any idea why please let me know. Thanks
UPDATE: the server was being finicky so I deleted and retyped the same code over again, as well as deleting and recreating the same cronjob and it works properly.
you may have had some white-space in your code that was causing the server to hang. could also be a bad cron path. check your cron logs to see what is causing the server load.