notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (19), scripting (5), bash (4), linux (3), html (2), markdown (2), obsidian (2), shortcuts (2), ActivityPub (1), advent-of-code (1) ............ see all (+15)

viewing a single note

cron jobs are hard to make # source

tags: cron • 368 'words', 110 secs @ 200wpm

cron jobs are a great tool, but it's very difficult to test them. a lot of the time, I create a cron job, and simply check back a day later to see if it did anything.

I've now developed a process (when making something work that's super annoying, you stick to your solution, even if it's hacky), which is:

before I did this, I was making sure that the scripts I made worked when called from any directory (i.e., by making each call to a file use "${root_directory}/${file}"). This was kind of annoying and I much prefer the "just cd into the directory before running the script" method.

Here are all of my current cron jobs on my server currently:

0 10 * * * /home/alifeee/scripts/combine_treehouse.sh >> /home/alifeee/scripts/cron.log 2>&1

0 11 * * * /var/www/ringram/next.sh >> /var/www/ringram/cron.log 2>&1
0 23 * * * /var/www/ringram/update.sh >> /var/www/ringram/cron.log 2>&1

# clean up old calendar events
0 23 * * * /var/www/simple-calendar/hoover.py >> /var/www/simple-calendar/cron.log 2>&1

# new weather map every 15 mins
*/15 * * * * (cd /usr/alifeee/weather_landscape; /usr/alifeee/weather_landscape/.venv/bin/python /usr/alifeee/weather_landscape/make_image.py >> /usr/alifeee/weather_landscape/cron.log 2>&1)

# get latest sheffield events
0 3 * * * (cd /usr/alifeee/sheffield-events/; echo "" > cron.log)
0 4 * * * (cd /usr/alifeee/sheffield-events/; ./get_all.sh >> cron.log 2>&1)

some of the commands could really be simpler, but as I said: "if it works: I will leave it until it breaks"

they are related to these projects (match them up yourself):

back to top back to main page