This commit is contained in:
Alban Bronisz 2021-12-15 11:48:01 +01:00
parent 9a3be2200b
commit 7aaae9cd6d
2 changed files with 9 additions and 5 deletions

View File

@ -15,15 +15,15 @@ Use
To add it to the cron tab:
crontab -e
sudo /etc/crontab
The add new line (to run the check once per hour)
The add new line (to run the check once per hour), don't forget to change the username:
1 * * * * /home/alban/outils/warn-if-broken/warn-if-broken-url.sh >/dev/null 2>&1
1 * * * * username /home/caracals/outils/warn-if-broken-url/warn-if-broken-url.sh > /dev/null 2>&1
**Note:**
- Normaly cron send task outputs (echo) via mail. As the MTA (Mail Transfert Agent), may not be set up,
the crontab line redirect the outputs into `/dev/null`.
- No sudo is needed, msmtp and crontab are call with current user.
- Sudo is needed to update the crontab. It also possible to set up your user crontab with `crontab -e`. In this case, remove `username` from the cron entry.
- The logs can be seen using (with sudo): `sudo grep CRON /var/log/syslog`

View File

@ -4,10 +4,13 @@ set -eu
URL="https://status.caracals.org"
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# Move in repo folder
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
pushd ${SCRIPT_PATH} > /dev/null
# Test URL
if ret=$(curl -s -f "${URL}"); then
echo "Marche"
else
@ -15,4 +18,5 @@ else
cat msg.txt | msmtp alban.bronisz@gmail.com
fi
# Move back
popd