Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- log_dir="/var/log"
- logs_ver=( "wtmp" "wtmp.1" "wtmp.2" "wtmp.3" )
- #last_state=( "crash" "shutdown" "reboot" )
- #crash_status=`last -a -x | grep crash`
- #shutdown_status=`last -a -x | grep shutdown`
- #status_report=`last -a -x | grep $last_state`
- for i in ${logs_ver[@]}; do
- wtmp_logs=$log_dir/$i
- if [ -f "$wtmp_logs" ]; then
- echo "wtmp log existed $wtmp_logs"
- if last -a -x -f $wtmp_logs| grep "crash";
- then echo "Status report is CRASH"
- elif last -a -x -f $wtmp_logs| grep "shutdown";
- then echo "Shutdown process detected"
- else
- echo "not found"
- fi
- else
- echo "wtmp log not existed for $wtmp_logs"
- fi
- done
Add Comment
Please, Sign In to add comment