padosoft / kill-process Goto Github PK
View Code? Open in Web Editor NEWBash script to kill high CPU process, long running process and too much consuming memory process.
License: MIT License
Bash script to kill high CPU process, long running process and too much consuming memory process.
License: MIT License
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
If i put php-fpm in killlist, the sript check only first php-fpm process.
In real environment, multiple php-fpm process (one for site) is running with same process name and
different pid.
If a script in one site, for bug or an attack, consume 100% of cpu , i need to kill this pid.
Thanks
...
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
Found the issue, I was missing integer format from decimal.
CPU=${CPU%%[.,]*}
What exactly is MAX_SEC though?
If I set MAX_CPU=90 and MAX_SEC=30 does this mean it kills the process if reaches 90% CPU and stays that way for 30 seconds or if the process has been running for at least 30 seconds? I would like for the script to kill the process only if it stays at 90% for 30 seconds to avoid false-positive loads because sometimes it spikes to 90% for two or three seconds.
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
OS: Debian 8
No Process kill, CPU load 100 %
my config
#process command name to check
declare -a KILLLIST
KILLLIST=("/usr/bin/tor")
#max cpu % load
MAX_CPU=90
#max execution time for CPU percentage > MAX_CPU (in seconds 7200s=2h)
MAX_SEC=10
#max execution time for any %CPU (in seconds 2700s=45min)
MAX_SEC2=5
crontab check every minute
bash /root/myscript/kill-process/killprocess.sh kill top cpu > /var/log/killprocess.log 2>&1
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
Whenever I run the script (in usage screenshots, too), I see:
There isn't any matched process for /usr/sbin/apache2
Check /usr/bin/php5-cgi process...
There isn't any matched process for /usr/bin/php5-cgi
I was expecting it to either:
run ` bash killprocess.sh kill top cpu
Thanks!
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
line 349: 10#0+60*(10#: invalid integer constant (error token is "10#")
run script on centos 9 as a normal user
Hi @lopadova ,
Can you explain dry
option more? I can't understand that.
Also I think a little more detail and docs can be useful.
Thanks for your attention and for this awesome bash. ๐
Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].
In raising this issue, I confirm the following (please check boxes):
I check my killprocess.log, i get this info
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
Process execute in 'kill' mode.
Process fetched by 'top' command
Process sort by %CPU ( 9 )
Check /usr/bin/xxx process...
There isn't any matched process for /usr/bin/xxx
Modify only this
#max cpu % load
MAX_CPU=95
#max execution time for CPU percentage > MAX_CPU (in seconds 7200s=2h)
MAX_SEC=180
#max execution time for any %CPU (in seconds 2700s=45min)
MAX_SEC2=270
my crontab
0 * * * * bash /root/myscript/kill-process/killprocess.sh kill top cpu > /var/log/killprocess.log 2>&1
5 * * * * bash /root/myscript/kill-process/killprocess.sh kill top cpu > /var/log/killprocess.log 2>&1
10 * * * * bash /root/myscript/kill-process/killprocess.sh kill top cpu > /var/log/killprocess.log 2>&1
is my logfiles OK, or is wrong ?
cya
Betaman
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.