Use shell scripts on Linux to view memory conditions (ultra-practical), linuxshell
#! /Bin/bash
Export chknum = 1
# Shell mixing directory (the output log file is also stored in this directory after execution)
Echo 3>/wls/wls81/shell
Sync
While [$ chknum-ge 0]
Do
Echo "-------------------------------------------------------"> trace. log
Mt = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '1p''
Mu = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '2p''
Mf = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '3p''
St = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '9p''
Su = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '10p''
Sf = 'free | tr [: blank:] \ n | grep [0-9] | sed-n '11p''
T = 'expr $ mt + $ st'
U = 'expr $ mu + $ su'
Echo "Total Mem: $ t"
Echo "Used Mem: $ u"
R = 'expr $ mu \ * 100/$ mt'
Echo "current memory usage: $ R %"> trace. log
# Start to release the memory (only detect and delete this segment if no operation is performed)
If [$ R-gt 80]
Then
Echo "the monitor is more, please clean"
# Clear when the memory is executed> 80%. You can modify the following rules.
Ps-ef | grep java | cut-c 9-15 | xargs kill-9
Fi
# Release ended
Echo "$ R"> memory. log
Echo "record time:"> trace. log
Echo 'date'> trace. log
Echo "-------------------------------------------------------"> trace. log
Sleep 24 h
Done
* ****************** I am a handsome splitting line *************** ********
After the script is completed, add Jenkins to set the scheduled task. Set the time to run once a day. I am no longer afraid that the Environment crashes due to memory problems every day.