From 7aaae9cd6d8842c9fb8fe6afc167576e5836a078 Mon Sep 17 00:00:00 2001 From: Alban Bronisz Date: Wed, 15 Dec 2021 11:48:01 +0100 Subject: [PATCH] Doc --- README.md | 8 ++++---- warn-if-broken-url.sh | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4210681..b92a805 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/warn-if-broken-url.sh b/warn-if-broken-url.sh index 2e15bb5..3f3f2e8 100755 --- a/warn-if-broken-url.sh +++ b/warn-if-broken-url.sh @@ -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