Last active
December 15, 2024 08:18
-
-
Save supersonictw/ef01b51032cff6299246abe02de04099 to your computer and use it in GitHub Desktop.
Execute daily tasks and sends a notification upon successful completion.
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/sh | |
# daily_tasks.sh - Execute daily tasks and sends a notification upon successful completion. | |
# SPDX-License-Identifier: MIT (https://ncurl.xyz/s/o_o6DVqIR) | |
# https://gist.github.com/supersonictw/ef01b51032cff6299246abe02de04099 | |
# crontab -e | |
# 0 3 * * * sh /somewhere/daily_tasks.sh >/dev/null 2>&1 # execute silently at 3 a.m every day | |
NOTIFY() { | |
DATE_NOW="$(date)" | |
curl \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
-d "{\"content\":\"Task has been executed at \`$DATE_NOW\`.\"}" \ | |
"$1" | |
} | |
sh "your_task_here.sh" && | |
NOTIFY "https://your_webhook.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment