Created
March 15, 2024 00:46
-
-
Save meyt/4e45ca0fc2f8095e166359b13db7cc40 to your computer and use it in GitHub Desktop.
Get nmcli connection uptime
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 | |
# Usage: ./conn-uptime.sh MyConnectionName | |
conn=$1 | |
timestamp1=$(nmcli -f connection.timestamp conn show $conn | awk '{print $2}') | |
current_time=$(date +%s) | |
duration=$((current_time - timestamp1)) | |
echo "Duration since last network connection: $duration seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment