-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_reboot.sh
More file actions
17 lines (14 loc) · 882 Bytes
/
Copy pathcheck_reboot.sh
File metadata and controls
17 lines (14 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
user_date=$(last --time-format=iso $USER | head -2 | tail -1 | perl -pe 's/.*(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d).*/$1/g')
reboot_date=$(last --time-format=iso reboot | head -1 | perl -pe 's/.*(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d).*/$1/g')
epoch_user=$(date -d "${user_date}" +"%s")
epoch_reboot=$(date -d "${reboot_date}" +"%s")
if [ "$epoch_user" -lt "$epoch_reboot" ]; then
echo "############################################################"
echo "# #"
echo "# #"
echo "# SYSTEM REBOOTED SINCE LAST LOGIN #"
echo "# #"
echo "# #"
echo "############################################################"
fi