Skip to content

Instantly share code, notes, and snippets.

@ederparaiso
Created May 3, 2022 21:39
Show Gist options
  • Save ederparaiso/c8cf09b067bbb729220e27ccf1c7c6ba to your computer and use it in GitHub Desktop.
Save ederparaiso/c8cf09b067bbb729220e27ccf1c7c6ba to your computer and use it in GitHub Desktop.
docker system prune cron job with discord notification
#!/bin/sh
docker system prune --force
OUT=$?
WEBHOOK_URL="url webhook discord"
if [ $OUT = 0 ]
then
STATUS="Ok"
COLOR="484378"
else
STATUS="Fail"
COLOR="11796740"
fi
curl $WEBHOOK_URL -H "Content-Type: application/json" -d '{ "content": null, "embeds": [{ "title": "Cron Job", "description": "Maintenance command executed on machine\n**Command:** `docker system prune --force`\n**Destination:** nginx-proxy (gcloud vm)\n**Status:** '$STATUS'", "color": '$COLOR' }] }'
# chmod +x "script.sh"
# crontab -e
# * * * * * sh script.sh >/dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment