shell - killall httpd for sleep process -
This shell explains the problem after stopping the .sh file, and nothing can be done, where is my clue
Kill your HTPD if there is more than 10 sleeping processes and start httpd with zero sleeping process
#! / Bin / bash #this always means loop [1]; What HTTP = `ps auwxf | GRP httpd | Grep -v grep | Wc -l`; # The number of httpd processes that run # in the above line is counted and the following line states that if [$ [HTTP] -lt 10] is running, at least 10 are found; So killall-9 httpd; #included If now, then less then 10, kill them all and wait 1 second sleep; #start Apache start /etc/init.d/httpd; Fi; # Everything did, sleep for ten seconds before we sleep again 10; Done
Why will you kill child procedures? If you do that you are killing all running sessions, will not it be easy to setup your webserver configuration so that it matches your needs?
As Dennis has already mentioned that should look like your script:
#! / Bin / Bash BINNAME = httpd # Name of the process TIMEOUT = 10 # seconds to wait for the next loop MAXPROC = 10 # The maximum amount of procs for the given daemon while not the correct number of # procs HTTP = `pgrep $ BINNAME | If more "$ HTTP" -gt "$ MAXPROC"] are running $ MAXPROC then call # kill killall-9 $ BINNAME sleep1 # start http again /etc/init.d/httpd start To start $ TIMEOUT
makes the presentation code more readable;)
Comments
Post a Comment