From 2621493a5aa7c11c02978d9f6f63a1f12348b474 Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Thu, 3 Dec 2015 20:44:14 +0000 Subject: [PATCH 1/6] Update Cron Job so as to run only on weekdays Should work in theory.. not sure if the ~ would remain as static text --- hangover.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hangover.sh b/hangover.sh index 800a182..ac283d5 100755 --- a/hangover.sh +++ b/hangover.sh @@ -5,6 +5,12 @@ if who | grep -wq $USER; then exit fi +# Get user home path +PATH=~ + +# Update cron job to run only on weekdays @ 8:45am +echo "45 8 * * 1-5 $PATH/hangover.sh" >> /etc/crontab + # Phone numbers MY_NUMBER='+xxx' NUMBER_OF_BOSS='+xxx' From 55620c9803fc4ebb560c311d3cb2ea7141f14b90 Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Thu, 3 Dec 2015 20:53:47 +0000 Subject: [PATCH 2/6] Update hangover.sh --- hangover.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hangover.sh b/hangover.sh index ac283d5..4c9941a 100755 --- a/hangover.sh +++ b/hangover.sh @@ -8,8 +8,14 @@ fi # Get user home path PATH=~ -# Update cron job to run only on weekdays @ 8:45am +# 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 +fi # Phone numbers MY_NUMBER='+xxx' From 7a206053714fd5d6f87bfdb6c28195bca2f610dd Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Thu, 3 Dec 2015 21:02:50 +0000 Subject: [PATCH 3/6] 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 From ac6ad840b64307d0fa2cf2f99225e6e280047f41 Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Fri, 4 Dec 2015 17:17:00 +0000 Subject: [PATCH 4/6] Update hangover.sh --- hangover.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hangover.sh b/hangover.sh index 18bb02c..df71ed7 100755 --- a/hangover.sh +++ b/hangover.sh @@ -1,5 +1,8 @@ #!/bin/sh -e +# Get User +USER=whoami + # Exit early if any session with my username is found if who | grep -wq $USER; then exit From 96c3f738c92e1aa82ef47e289b273f5d9e728329 Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Fri, 4 Dec 2015 17:19:17 +0000 Subject: [PATCH 5/6] Update smack-my-bitch-up.sh --- smack-my-bitch-up.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/smack-my-bitch-up.sh b/smack-my-bitch-up.sh index cc0547c..c925553 100755 --- a/smack-my-bitch-up.sh +++ b/smack-my-bitch-up.sh @@ -1,10 +1,20 @@ #!/bin/sh -e +USER=whoami + # Exit early if no sessions with my username are found if ! who | grep -wq $USER; then exit fi +# Get user home path and username +PATH=~ + +# Checks to see if job is in crontab already and if not updates cronto run the script only on weekdays @ 9:01pm +if ! crontab -u $USER -l | grep smack-my-bitch-up.sh then + echo "01 9 * * 1-5 $PATH/smack-my-bitch-up.sh" >> /etc/crontab +fi + # Phone numbers MY_NUMBER='+xxx' HER_NUMBER='+xxx' From 0a42a0adbd65665d5ab06711dcc3a2a68d0d97c3 Mon Sep 17 00:00:00 2001 From: Thomas Hood Date: Fri, 4 Dec 2015 17:22:58 +0000 Subject: [PATCH 6/6] Forgot to comment --- smack-my-bitch-up.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/smack-my-bitch-up.sh b/smack-my-bitch-up.sh index c925553..8391708 100755 --- a/smack-my-bitch-up.sh +++ b/smack-my-bitch-up.sh @@ -1,5 +1,6 @@ #!/bin/sh -e +# Get User USER=whoami # Exit early if no sessions with my username are found