From 7a206053714fd5d6f87bfdb6c28195bca2f610dd Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Thu, 3 Dec 2015 21:02:50 +0000 Subject: [PATCH] hangover.sh cron update 2.0 Should be okay, so when the user puts the script into his home directory and runs it --- hangover.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hangover.sh b/hangover.sh index 4c9941a..18bb02c 100755 --- a/hangover.sh +++ b/hangover.sh @@ -5,16 +5,12 @@ if who | grep -wq $USER; then exit fi -# Get user home path +# Get user home path and username PATH=~ -# Get day in shellscript -DATE=date +%A - -# On Saturday when hangover.sh runs, update cron job to run only on weekdays @ 8:45am then exit -if $DATE == "Saturday" then -echo "45 8 * * 1-5 $PATH/hangover.sh" >> /etc/crontab -exit +# Checks to see if job is in crontab already and if not updates cronto run the script only on weekdays @ 8:45am +if ! crontab -u $USER -l | grep hangover.sh then + echo "45 8 * * 1-5 $PATH/hangover.sh" >> /etc/crontab fi # Phone numbers