The transient service maker lets you run commands in the
background, and it does so by wrapping those commands in transient
services (see Defining Services). It is similar to the
systemd-run
command, which you might have encountered before.
A simple configuration file that uses this service looks like this:
(use-modules (shepherd service transient)) (register-services (list (transient-service)))
This creates a service called transient
that has a spawn
action, which you can use like this:
# Run 'make' from the current directory. herd spawn transient -d "$PWD" -- make -j4 # Run 'rsync' from the home directory, inheriting # the 'SSH_AUTH_SOCK' environment variable. herd spawn transient \ --log-file=backup.log \ -E SSH_AUTH_SOCK=$SSH_AUTH_SOCK -- \ rsync -e ssh -vur . backup.example.org:
Each of these herd spawn transient
commands creates a new
transient service. Like any other service, they can be inspected and
stopped. Running herd stop transient
stops all the currently
running transients.
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.
Return a service with the given provision and
requirement. The service has a spawn
action that lets users run
commands in the background.