Script-for-GUI-cron-control-oom: Difference between revisions
Jump to navigation
Jump to search
(Created page with " #!/bin/bash #verbose 0=none 1=logfile verbose='1' logfile='/root/script/check_php.log' #logfile='/dev/stdout' #limit is in kB (100000=100MB, 5000000=5GB) prcL=5000000...") |
No edit summary |
||
Line 22: | Line 22: | ||
if [ "9$prcM" \> "9$prcL" ]; then | if [ "9$prcM" \> "9$prcL" ]; then | ||
if [ "$verbose" -ge "1" ]; then | if [ "$verbose" -ge "1" ]; then | ||
echo "$rundate | echo "$rundate set oom_adj_score=$oom_adj_score for PID:$prc" >> $logfile | ||
echo " Mem VSize $prcM Kb | echo " Mem VSize $prcM Kb limit is $prcL Kb" >> $logfile | ||
detail=$(ps -q $prc -eo pid:16,cmd:50,etime:20) | detail=$(ps -q $prc -eo pid:16,cmd:50,etime:20) | ||
echo "$detail" >> $logfile | echo "$detail" >> $logfile |
Revision as of 12:56, 18 April 2019
#!/bin/bash #verbose 0=none 1=logfile verbose='1' logfile='/root/script/check_php.log' #logfile='/dev/stdout' #limit is in kB (100000=100MB, 5000000=5GB) prcL=5000000 #oom_score_adj to set when process over limit oom_adj_score=1000 #list of processes prcs=$(pgrep php) for prc in $prcs; do prcM=$(cat /proc/$prc/status|grep VmSize| cut -d ':' -f2|rev|cut -d ' ' -f2|rev|xargs) prcP="/proc/$prc" prcC=`cat $prcP/cmdline` scP="$prcP/oom_score_adj" scV=$(cat $scP) rundate=$(date) if [ "9$prcM" \> "9$prcL" ]; then if [ "$verbose" -ge "1" ]; then echo "$rundate set oom_adj_score=$oom_adj_score for PID:$prc" >> $logfile echo " Mem VSize $prcM Kb limit is $prcL Kb" >> $logfile detail=$(ps -q $prc -eo pid:16,cmd:50,etime:20) echo "$detail" >> $logfile echo >> $logfile fi echo $oom_adj_score >> $scP fi done