Skip to content

Instantly share code, notes, and snippets.

@risadams
Created July 6, 2023 10:23
Show Gist options
  • Save risadams/82271a83b97188b13b176d20f5063b67 to your computer and use it in GitHub Desktop.
Save risadams/82271a83b97188b13b176d20f5063b67 to your computer and use it in GitHub Desktop.
#!/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