Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IDLES=0
- while sleep 30
- do
- PCT=`top -bn 2 -d 0.1 | grep '^%Cpu' | tail -n 1 | tr :. ' ' | awk '{print$2}'`
- if [ $PCT -lt 10 ]
- then
- IDLES=$[$IDLES+1]
- #echo $IDLES $PCT
- else
- IDLES=0
- fi
- if [ $IDLES -ge 20 ]
- then
- sudo shutdown -h now
- break
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement