Scron

Scheduler for Laptops

Scron schedules commands to run daily, weekly, monthly, or annually. If your machine is
off, scron will attempt to run a scheduled as soon as possible. See Scron on GitHub.

Install

$ crontab -e
0 */2 * * * scron -r

Get the latest release binary for your system. Then configure cron to run it every two hours.

Configuration

# in ~/.scron file
1d         daily-cmd
7d         7-days-cmd
Mo,Fr      mondays-and-fridays-cmd
1st,23rd   twice-a-month-cmd
4/15       once-a-year-cmd
# example: run backup script every two days
2d /path/to/backup.sh arg1 arg2

# example: tell yourself Happy Birthday every year
3/14 say "Happy Birthday!"

Scron can be configured via the ~/.scron file. It uses a simple format: left column for schedule and right column for unix command. Comment lines start with #. Blank lines are ignored.

Scron will attempt to run whenever a schedule goes stale. For example, if its been 25 hours since the last run and the command is scheduled for 1d. Or if your laptop was off on Friday but on Saturday, and the command was scheduled for Fridays.

Custom Options

# in ~/.scrondb
2020-03-14.02:00 say "Happy Birthday!" 
2020-05-20.04:00 /path/to/backup.sh arg1 arg2
# in ~/.scronlog
=> 2020-05-20.04:00 running
=> 2020-05-20.04:00 /path/to/backup.sh arg1 arg2 (start)
Running backup...
Backup was successful!
=> 2020-05-20.04:00 /path/to/backup.sh arg1 arg2 (exit=0)
=> 2020-05-20.04:00 finished

Last run timestamps are stored in ~/.scrondb. STDOUT of commands with timestamps are logged in ~/.scronlog. Commands returning non-zero status are considered a failure. Scron will try to re-run them after two hours.