Created
July 23, 2026 21:59
-
-
Save saudiqbal/69f62d4bc125fc69bf8983b17a54417c to your computer and use it in GitHub Desktop.
Notify once within time stamp then send again once time passes
This file contains hidden or 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 | |
| timestampvalue=$(journalctl -n 1 -t LastNotifyTimeStamp | grep "TimeStamp=" | cut -d'=' -f2-) | |
| if [[ -n "$timestampvalue" ]]; then | |
| echo "Last Value: $timestampvalue" | |
| CurrentTimeStamp=$(date +%s) | |
| CurrentTimeStamp=$((CurrentTimeStamp - 60)) | |
| echo "Current Value: $CurrentTimeStamp" | |
| if [ "$CurrentTimeStamp" -gt "$timestampvalue" ]; then | |
| echo "Time Expired" | |
| date=$(date +%s) | |
| logger -t LastNotifyTimeStamp -p warning "TimeStamp=$date" | |
| else | |
| echo "Time within limit" | |
| fi | |
| else | |
| echo "Time Expired, continue" | |
| date=$(date +%s) | |
| logger -t LastNotifyTimeStamp -p warning "TimeStamp=$date" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment