Skip to content

Instantly share code, notes, and snippets.

@saudiqbal
Created July 23, 2026 21:59
Show Gist options
  • Select an option

  • Save saudiqbal/69f62d4bc125fc69bf8983b17a54417c to your computer and use it in GitHub Desktop.

Select an option

Save saudiqbal/69f62d4bc125fc69bf8983b17a54417c to your computer and use it in GitHub Desktop.
Notify once within time stamp then send again once time passes
#!/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