Skip to content

Instantly share code, notes, and snippets.

@alanhussey
Last active April 25, 2018 21:51
Show Gist options
  • Save alanhussey/0f5ccbd1f28e1c7d2c851bff5c496889 to your computer and use it in GitHub Desktop.
Save alanhussey/0f5ccbd1f28e1c7d2c851bff5c496889 to your computer and use it in GitHub Desktop.
How I run golden-hour
#!/bin/bash
set -e;
set -x;
GOLDEN_HOUR_DIR="$(dirname "$(realpath $0)")"
GOLDEN_HOUR_PATH="$GOLDEN_HOUR_DIR/main.py"
VENV_DIR="$HOME/.virtualenvs/golden-hour"
source "$VENV_DIR/bin/activate"
PATH="$PATH:/usr/local/bin"
date
# 7200 seconds with a frame every 8 seconds, starting 60 minutes before sunset
python3 $GOLDEN_HOUR_PATH \
--start-before-sunset 60 \
--duration 7200 \
--interval 8 \
--darksky-key=REDACTED \
--post-to-twitter

Here's my crontab. 0 22 * * * happens to be 3pm local time for goldenhourSEA, which is early enough that the earliest sunset of the year will be ~1 hour after start.

I redirect stdout and stderr to error.log, but I haven't really needed to check that recently, so I don't know how useful that actually is.

$ crontab -l | grep golden-hour
0 22 * * *   cd /home/pi/Projects/golden-hour; bash ./run.sh >> error.log 2>&1

To test I make a copy of run.sh and update the flags as needed.

I also ping https://healthchecks.io before starting and after finishing, just in case something goes wrong.

As you may have guessed, I am not a DevOps Engineer in my day-job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment