///
Search
🩳

Process check

PN=`basename "$0"` # Program name VER=`echo '$Revision: 1.2 $' | cut -d' ' -f2` Tmp=${TMPDIR:-/tmp}/top$$ # Temporary file if [ -x /usr/ucb/ps ] then PS=/usr/ucb/ps else PS=ps fi if $PS aux >/dev/null 2>&1 then # BSD ps DefPsArgs=aux else # SYSV ps DefPsArgs=-ef fi Usage () { echo "$PN - show top cpu processes, Version $VER (stv '94) usage: $PN [-<ps_opt>] [lines [interval]] ps_opt: options for ps (default is $DefPsArgs) The default for the number of lines is 20, the default interval is 3 seconds." >&2 exit 1 } while [ $# -gt 0 ] do case "$1" in --) shift; break;; -h) Usage;; -*) PsArgs="$1";; *) break;; # number of lines esac shift done : ${PsArgs:=${DefPsArgs}} Lines=${1:-20} # Number of lines to display Interval=${2:-3} # Time interval (in seconds) # Remove temporary file at exit or signal trap "rm -f $Tmp" 0 trap "exit 1" 1 2 3 15 while true do # Temporary file is not necessary but faster $PS $PsArgs > $Tmp clear head -$Lines $Tmp sleep $Interval done
JavaScript
복사