Skip to content

Commit 720e47d

Browse files
committed
Update cronjobs
- add cronjob to backup timewarrior log - add cronjob to delete ~/Downloads/MSTeams - update Readme.md
1 parent 3c70199 commit 720e47d

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

cron/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
This folder contains scripts that are intenden to be implemented as cron jobs.
1+
This folder contains scripts that are intenden to be implemented as cron jobs. Most of them run at night, e.g. at 4am. They even run when the MacBook lid is closed. But I think it has to be connected to power.
22

3-
`cronjobs.sh` is a special script that is used for debugging and demonstration purposes only.
3+
View the logs by simply typing `mail` in your console. Cron sends a mail to localhost whenever the task is finished containing all the output.
4+
5+
The current list of cronjobs looks as below (`contab -l`). Check the different scripts for an explanation of what they're doing:
6+
7+
```shell
8+
SHELL=/bin/zsh
9+
PATH=/opt/homebrew/sbin:/opt/homebrew/bin:/usr/bin:/usr/sbin:/bin:/sbin:${PATH}"
10+
11+
# “At 04:00 every day”
12+
0 4 * * * /Users/stherold/dev/scripts/cron/backup-zsh-history.sh
13+
# “At 00:01 on every day-of-week from Tuesday through Saturday.”
14+
1 0 * * 2-6 /Users/stherold/dev/scripts/cron/backup-timewarrior-daily.sh
15+
0 4 * * * /Users/stherold/dev/scripts/cron/update-local-brew-package-library.sh
16+
0 4 * * * /Users/stherold/dev/scripts/cron/delete-teams-folder.zsh
17+
# * * * * * /opt/homebrew/bin/direnv exec . /Users/stherold/dev/scripts/cron/cronjobs.sh
18+
```

cron/backup-timewarrior-daily.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env zsh
2+
3+
# Backs up my timewarrior daily working time info from YESTERDAY so that I
4+
# have a chance to find out what went wrong with balance report.
5+
#
6+
# It should run one minute after midnight so it does not capture the time when
7+
# working past midnight.
8+
#
9+
# The generated timestamp always prints the time from yesterday.
10+
11+
echo "$(timew balance ioki 2023-11-13 - today && timew summary :yesterday :ids)" > "~/docs/_backups/timewarrior/working-time/$(date -v-1d +%F-%A)"

cron/cronjobs.sh

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

3+
#
4+
# Special script that is used for debugging and demonstration purposes only.
35
#
46
# The crontab entry must look like below to execute the script at midnight
57
# every day and properly load the .envrc file so we have access to the loaded

cron/delete-teams-folder.zsh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env zsh
2+
3+
# Deletes the folder ~/Downloads/MSTeams since this is regenerated all the time and MS Teams
4+
# stores some kind of VERY large data in there (>50GB)
5+
6+
folder="/Users/stherold/Downloads/MSTeams"
7+
8+
if [ -d "$folder" ]; then
9+
rm -rf "$folder"
10+
fi

0 commit comments

Comments
 (0)