Created
July 6, 2023 10:23
-
-
Save risadams/82271a83b97188b13b176d20f5063b67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
last_login=$(last -1 $USER | awk '{print $5,$6,$7}') # Get the last login timestamp | |
last_boot=$(who -b | awk '{print $3,$4}') # Get the system boot timestamp | |
if [[ $last_boot > $last_login ]]; then # Compare timestamps | |
echo "The system has rebooted since the last login." | |
else | |
echo "The system has not rebooted since the last login." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment