Skip to content

Instantly share code, notes, and snippets.

@artsi0m
Last active February 26, 2026 14:34
Show Gist options
  • Select an option

  • Save artsi0m/51e644b9d4eff2340fef4abf0ba13656 to your computer and use it in GitHub Desktop.

Select an option

Save artsi0m/51e644b9d4eff2340fef4abf0ba13656 to your computer and use it in GitHub Desktop.
Get last post from a static page
#!/usr/bin/env sh
set -e
set -o errexit
Url=$1
Sleep_Arg=$2
usage() {
echo "Usage: ./last-post.sh [url] [check interval: default is 1 min]"
echo "Dependencies: curl, mail, Last-Modified http header"
}
get_http_header_last_modified () {
curl "$1" --output /dev/null --silent --dump-header - \
| grep Last-Modified
}
notify_mail() {
[ "$1" != "$2" ] \
&& printf 'Page on address %s updated' "$3" \
| mail -s 'Page updated' "$USER"
}
main () {
Last_Modified_First="$(get_http_header_last_modified "$Url")";
sleep "$Sleep_Arg"
Last_Modified_Second="$(get_http_header_last_modified "$Url")";
notify_mail "$Last_Modified_First" "$Last_Modified_Second" "$Url"
}
[ -z "$Sleep_Arg" ] && Sleep_Arg=60
while true;
do
if [ -z "$Url" ]; then
usage; exit 0;
else main;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment