Snooze: Run a Command at a Particular Time

thunderbong1 pts0 comments

GitHub - leahneukirchen/snooze: run a command at a particular time · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

leahneukirchen

snooze

Public

Notifications<br>You must be signed in to change notification settings

Fork<br>16

Star<br>276

master

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>53 Commits<br>53 Commits

sv

sv

Makefile

Makefile

NEWS.md

NEWS.md

README.md

README.md

snooze.1

snooze.1

snooze.c

snooze.c

View all files

Repository files navigation

snooze: run a command at a particular time

snooze is a new tool for waiting until a particular time and then<br>running a command. Together with a service supervision system such as<br>runit, this can be used to replace cron(8).

snooze has been tested on Linux 4.2.<br>It will likely work on other Unix-like systems with C99.

Benefits

Over cron:

mnemonic syntax

no overlapping job runs possible

filtering by ISO week and day of year

due to supervision, no centralized daemon required

due to supervision, can easily disable jobs or force their<br>execution instantly

due to supervision, have custom logs

due to no centralized daemon, no fuzzing with multiple users/permissions

very robust with respect to external time changes

can use a file timestamp to ensure minimum waiting time between two<br>runs, even across reboots

randomized delays (some cron have that)

variable slack (no need for anacron)

ad-hoc usage possible, just run the program from command line

Over runwhen:

less confusing usage (I hope)

filtering by ISO week and day of year

zero dependencies

Over uschedule:

due to supervision, no centralized daemon required

filtering by ISO week and day of year

Over systemd timers:

mnemonic syntax

less complexity for jobs, no need for a .timer file distinct<br>from the .service file,

can use a file timestamp to ensure minimum waiting time between two<br>runs, even across reboots

very robust with respect to external time changes

randomized delays

variable slack

ad-hoc usage possible, just run the program from command line

Rosetta stone

run five minutes after midnight, every day:<br>cron: 5 0 * * *<br>snooze: -M5

run at 2:15pm on the first of every month:<br>cron: 15 14 1 * *<br>snooze: -d1 -H14 -M15

run at 10 pm on weekdays:<br>cron: 0 22 * * 1-5<br>snooze: -w1-5 -H22

run 23 minutes after midnight, 2am, 4am ..., everyday:<br>cron: 23 0-23/2 * * *<br>snooze: -H/2 -M23

run every second week:<br>snooze: -W/2

run every 10 days:<br>snooze: -D/10

Usage:

snooze [-nv] [-t timefile] [-T timewait] [-R randdelay] [-s slack] [-d mday] [-m mon] [-w wday] [-D yday] [-W yweek] [-H hour] [-M min] [-S sec] COMMAND...

-n: dry-run, print the next 5 times the command would run.

-v: verbose, print scheduled (and rescheduled) times.

-t, -T: see below timefiles

-R: add between 0 and RANDDELAY seconds to the start of the scheduled time.

-J: add between 0 and JITTER seconds to scheduled execution time.

-s: commands are executed even if they are SLACK (default: 60) seconds late.

The durations RANDDELAY and JITTER and SLACK and TIMEWAIT are parsed as seconds,<br>unless a postfix of m for minutes, h for hours, or d for days is used.

The remaining arguments are patterns for the time fields:

-d: day of month

-m: month

-w: weekday (0-7, sunday is 0 and 7)

-D: day of year

-W: ISO week of year (0..53)

-H: hour

-M: minute

-S: second

The following syntax is used for these options:

exact match: -d 3, run on the 3rd

alternation: -d 3,10,27, run on 3rd, 10th, 27th

range: -d 1-5, run on 1st, 2nd, 3rd, 4th, 5th

star: -d '*', run every day

repetition: -d /5, run on 5th, 10th, 15th, 20th, 25th, 30th day

shifted repetition: -d 2/5, run on 7th, 12th, 17th, 22nd, 27th day

and combinations of those, e.g. -d 1-10,15/5,28.

The defaults are -d* -m* -w* -D* -W* -H0 -M0 -S0, that is, every midnight.

Note that all patterns need to match (contrary to cron where either<br>day of month or day of week matches), so -w5 -d13 only runs on<br>Friday the 13th.

Timefiles

Optionally, you can keep track of runs in time files, using -t and<br>optionally -T.

When -T is passed, execution will not start...

snooze time command cron week search

Related Articles