Using cron to create a schedule for your loopΒΆ

You should use cron to create a schedule for your loop. Use oref0 cron-5-minute-helper to generate a simple cron job. It can be imported into crontab using oref0 cron-5-minute-helper do-loop | crontab -. By default, it will list a suggested cron job that runs once every 5 minutes.

Here’s an example:

$ oref0 cron-5-minute-helper openaps do-foo-bar
SHELL=/bin/bash
PATH=/home/bewest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/bewest/.cabal/bin:/home/bewest/.cabal/bin

*/5 * * * * (cd /home/bewest/src/openaps/docs && time openaps do-foo-bar) 2>&1 | logger -t openaps-loop

It prepares a cron template to change to the current directory and runs whatever was specified, sending all output to syslog.