LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   system script (https://www.linuxquestions.org/questions/linux-newbie-8/system-script-914161/)

ust 11-17-2011 09:54 PM

system script
 
In my unix / linux server , there are always many process running in high CPU and use much memory , it makes the system run very slow .

Can advise if I would like to find it out , find and kill the processes which are

1) running over 3 hours with 90% CPU .
2) the process run over 12 hours

Can advise how can I write it ? or I guess these are very useful unix admin script , can advise where I can find the similiar one ?

Thanks.
.

fukawi1 11-17-2011 10:40 PM

Killing processes willy nilly via a script is probably not a good idea.

Look at top and ps to try and find out what is chewing the resources, and then try to diagnose why.

Killing critical system services (httpd on a webserver for example) is obviously, not a good idea.

jmc1987 11-17-2011 10:51 PM

Agreed.

If you kill random scripts that are using high resources you may render your system unstable. If need to investigate what is causing it. Some times this kinda thing can happen when you update your system and get a bug. I've had plenty of those in the past and just watched top mostly and figured it out. If this is a web server and your server becomes under a load due to high demand in request and it kills your web server then what happens lol. Think about what your doing and do it right.

tollingalong 11-17-2011 10:53 PM

You can find how long a process is running by looking at the process tree and comparing your current time (might be some other easier way too, dunno).

You can also do a ps auxwww --sort pcpu to find out what's been chewing your CPU time but um... killing processes without knowing what they are could be bad.


All times are GMT -5. The time now is 08:00 PM.