Skip to content

Instantly share code, notes, and snippets.

@meyt
Created March 15, 2024 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meyt/4e45ca0fc2f8095e166359b13db7cc40 to your computer and use it in GitHub Desktop.
Save meyt/4e45ca0fc2f8095e166359b13db7cc40 to your computer and use it in GitHub Desktop.
Get nmcli connection uptime
#!/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