Skip to content

Commit d42fb57

Browse files
committed
Merge pull request NARKOZ#45 from JulioOrdonezV/JulioOrdonezV-patch-1
Update cron job to execute scripts on weekdays
2 parents 61dbe67 + b9c6dad commit d42fb57

12 files changed

+6
-66
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ For Ruby scripts you need to install gems:
4242
## Cron jobs
4343

4444
```sh
45-
# Runs `smack-my-bitch-up.sh` daily at 9:20 pm.
46-
20 21 * * * /path/to/scripts/smack-my-bitch-up.sh >> /path/to/smack-my-bitch-up.log 2>&1
45+
# Runs `smack-my-bitch-up.sh` monday to friday at 9:20 pm.
46+
20 21 * * 1-5 /path/to/scripts/smack-my-bitch-up.sh >> /path/to/smack-my-bitch-up.log 2>&1
4747

48-
# Runs `hangover.sh` daily at 8:45 am.
49-
45 8 * * * /path/to/scripts/hangover.sh >> /path/to/hangover.log 2>&1
48+
# Runs `hangover.sh` monday to friday at 8:45 am.
49+
45 8 * * 1-5 /path/to/scripts/hangover.sh >> /path/to/hangover.log 2>&1
5050

5151
# Runs `kumar-asshole.sh` every 10 minutes.
5252
*/10 * * * * /path/to/scripts/kumar-asshole.sh
5353

54-
# Runs `fucking-coffee.sh` hourly from 9am to 6pm.
55-
0 9-18 * * * /path/to/scripts/fucking-coffee.sh
54+
# Runs `fucking-coffee.sh` hourly from 9am to 6pm on weekdays.
55+
0 9-18 * * 1-5 /path/to/scripts/fucking-coffee.sh
5656
```
5757

5858
---

fucking_coffee.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
# Skip on weekends
4-
exit if Time.now.saturday? || Time.now.sunday?
5-
63
# Exit early if no sessions with my username are found
74
exit unless `who -q`.include? ENV['USER']
85

hangover.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
# Skip on weekends
4-
exit if Time.now.saturday? || Time.now.sunday?
5-
63
# Exit early if sessions with my username are found
74
exit if `who -q`.include? ENV['USER']
85

hangover.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#!/bin/sh -e
22

3-
DAYOFWEEK=$(date +%u)
4-
5-
# Skip on weekends
6-
if [ "$DAYOFWEEK" -eq 6 ] || [ "$DAYOFWEEK" -eq 7 ]; then
7-
exit
8-
fi
9-
103
# Exit early if any session with my username is found
114
if who | grep -wq $USER; then
125
exit

python/fucking_coffee.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
#!/usr/bin/env python
22

3-
import datetime
43
import sys
54
import subprocess
65
import telnetlib
76
import time
87

9-
today = datetime.date.today()
10-
11-
# skip weekends
12-
if today.strftime('%A') in ('Saturday', 'Sunday'):
13-
sys.exit()
14-
158
# exit if no sessions with my username are found
169
output = subprocess.check_output('who')
1710
if 'my_username' not in output:

python/hangover.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
#!/usr/bin/env python
22

3-
import datetime
43
import os
54
import random
65
from twilio.rest import TwilioRestClient
76
from time import strftime
87
import subprocess
98

10-
today = datetime.date.today()
11-
12-
# skip weekends
13-
if today.strftime('%A') in ('Saturday', 'Sunday'):
14-
sys.exit()
15-
169
# exit if sessions with my username are found
1710
output = subprocess.check_output('who')
1811
if 'my_username' in output:

python/smack_my_bitch_up.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#!/usr/bin/env python
22

3-
import datetime
43
import os
54
import random
65
from twilio.rest import TwilioRestClient
76
import subprocess
87
import sys
98
from time import strftime
109

11-
12-
today = datetime.date.today()
13-
14-
# skip weekends
15-
if today.strftime('%A') == 'Saturday' || today('%A') == 'Sunday':
16-
sys.exit()
17-
1810
# exit if no sessions with my username are found
1911
output = subprocess.check_output('who')
2012
if 'my_username' not in output:

python3/fucking_coffee.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
import datetime
54
import telnetlib
65
import time
76

@@ -13,10 +12,6 @@
1312

1413

1514
def main():
16-
# Skip on weekends.
17-
if datetime.date.today().weekday() in (0, 6,):
18-
return
19-
2015
# Exit early if no sessions with my_username are found.
2116
if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
2217
return

python3/hangover.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
import datetime
54
import random
65

76
from twilio import TwilioRestException
@@ -18,10 +17,6 @@
1817

1918

2019
def main():
21-
# Skip on weekends.
22-
if datetime.date.today().weekday() in (0, 6,):
23-
return
24-
2520
# Exit early if any session with my_username is found.
2621
if any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
2722
return

python3/smack_my_bitch_up.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
import datetime
54
import random
65

76
from twilio import TwilioRestException
@@ -18,10 +17,6 @@
1817

1918

2019
def main():
21-
# Skip on weekends.
22-
if datetime.date.today().weekday() in (0, 6,):
23-
return
24-
2520
# Exit early if no sessions with my_username are found.
2621
if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')):
2722
return

smack-my-bitch-up.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#!/bin/sh -e
22

3-
DAYOFWEEK=$(date +%u)
4-
5-
# Skip on weekends
6-
if [ "$DAYOFWEEK" -eq 6 ] || [ "$DAYOFWEEK" -eq 7 ]; then
7-
exit
8-
fi
9-
103
# Exit early if no sessions with my username are found
114
if ! who | grep -wq $USER; then
125
exit

smack_my_bitch_up.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
# Skip on weekends
4-
exit if Time.now.saturday? || Time.now.sunday?
5-
63
# Exit early if no sessions with my username are found
74
exit if `who -q`.include? ENV['USER']
85

0 commit comments

Comments
 (0)