StLast=$(date +%s%N)
while true
do
#{ time date -Ins } &>>"$0_check.out"
# first {} to output time rst to out file, next {} to time all commands, (( and $(( to do math
{ time { St=$(date +%s%N) && NsTime=$((St-StLast-1000000000)) && StLast=$St && date -Ins && if (( NsTime > 500000000 )) ; then echo long time detect $((NsTime/1000000))ms; fi ; } } &>>"$0_check.out"
sleep 1
done
start:
nohup bash monitor_pause.sh &>/dev/null &
grep ouput
tail -f monitor_pause.sh_check.out |grep -C 10 long
tail -n 1000 -f monitor_pause.sh_check.out |grep -A 4 -B 6 long