5.4 Timer Service

The (shepherd service timer) provides the timer service, which lets you dynamically create timed services (see Timers), from the command line, in a way similar to the traditional at command:

# Run the 'mail' command, as root, as 12PM.
herd schedule timer at 12:00 -- \
  mail --to=charlie -s "Lunch time!"

# Run the 'mpg123' command as user 'charlie' at 7AM, from charlie's
# home directory.
herd schedule timer at 07:00 --user=charlie -- \
  mpg123 Music/alarm.mp3

# Run 'rsync' from the ~/doc directory, inheriting the 'SSH_AUTH_SOCK'
# environment variable.  Log the output in 'backup.log'.
herd schedule timer at 13:00 \
  --log-file=backup.log \
  -d ~/doc -E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \
  rsync -e ssh -vur . backup.example.org:

Each of these herd schedule timer commands creates a new timed service, which, like any other service, can be inspected and stopped; those services are transient and vanish after they have executed their command (see Defining Services).

The command runs from the directory specified by default-service-directory or from that specified by the --working-directory option of herd; it has with the environment variables in default-environment-variables, augmented with HOME when running as a different user, with the addition of variables passed with --environment-variable. See Invoking herd, for more info on influential command-line options.

This timer service can be added to your configuration like so:

(use-modules (shepherd service timer))

(register-services (list (timer-service)))

The reference follows.

Procedure: timer-service [provision] [#:requirement ’()]

Return a timer service with the given provision and requirement. The service has a schedule action that lets users schedule command execution similar to the venerable at command.