Created
May 3, 2022 21:39
-
-
Save ederparaiso/c8cf09b067bbb729220e27ccf1c7c6ba to your computer and use it in GitHub Desktop.
docker system prune cron job with discord notification
This file contains 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/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