ShutDown 100% processes - Automaticly
14 Replies
ulimit
A process that locks up and hangs at 100% is indicative of a more serious issue that you need to look into. The proper thing to do is fix or remove the offending process, rather than trying to kill it when it happens.
I got message form linode
"Your Linode, linode-1, has exceeded the notification threshold (90) for CPU Usage by averaging 104.0% for the last 2 hours. "
then i login and check "top" and find out a process that is taking 100% of CPU and time of it is 250 minutes.
So obviously this process is "jammed" somehow and will not terminate by itself. Ok I killed it there and not it's gone.
My idea would be that after 10 minutes or so this kind of processes is killed, data of it logged to my log file and then i check later what it was. Is this correct idea how to solve it and also can it be done this way or some othe way would be better?
It's relatively easy to write a shell script that runs from cron every few minutes, check the CPU usage, and email you a list of currently running processes if the CPU usage is above a certain threshold. Then you can ask around what might be causing Program X to use so much CPU.
It would be more difficult to automatically terminate the offending process without damaging whatever it was originally meant to be working on. You don't want a rogue script going off on a killing rampage and corrupting your database while doing so.
@marko_roi:
I killed it there and not it's gone.
If you have not done so yet, instead of "kill process" try "kill -9 process".
James
@zunzun:
@marko_roi:I killed it there and not it's gone.
If you have not done so yet, instead of "kill process" try "kill -9 process".
I think he was trying to write "now it's gone", not "it's not gone".
To hybinet, Apache was name of process. I think it would be safe to assume if someting is runing more than 10 minutes that it wouldnt work and should be shutdown. I can kill process manually but i am not always by computer and ready to kill it if its making problems, and then server stops working and I have a real problem and i dont even know as i might be on vacation or just off somewhere. Would like to have some trigger for this kind of events, but ok I can take your advice if all of you think its not a way to go.
kill
kill -9
What's MaxRequestsPerChild in your Apache configuration? Setting this to a low value (like 500) might help prevent PHP from going belly up, by forcing Apache processes to kill themselves every now and then. Of course this is a stupid band-aid solution, but you sometimes need stupid band-aid solutions if you want to use PHP. Also make sure that maxexecutiontime in php.ini is set to a reasonable value, like 15 seconds. This is another band-aid solution that might or might not work, but it's better than nothing. Google "
BTW, kill -9 is merciless. Try regular kill first. Resort to kill -9 only if regular kill doesn't work.
@marko_roi:
I am wondering, If some process is runing on 100% and jamming server for long time, is there a way that i could automaticly shut them down if for example more than 5 minutes they occupy 100% of server.
No way, not unless you had the permissions set that way on purpose. Is that a possibility?