Service management cheatsheet

These are a few commonly used commands. For more, see the manual pages of the service-control, system-control, shutdown, and rcctl programs. For exposition, we here assume that the cron service has its service bundle directory at, or accessible via a symbolic link at, /var/service-bundles/services/gcron.

Daemontools-style service management employs direct access to the service bundle directories.

OpenBSD-style, systemd-style, and SMF-style service management searches for service bundle directories in several well-known locations. The cron service (located in such a location) is simply denominated either cron.service or simply cron.

Associated log services are conventionally denominated cyclog@service-name, and pointed to from the logged service's service bundle by a log symbolic link. A service and its associated log service may, where such convention is adhered to, be named together using shell brace expansion: {cyclog@,}service-name.

Daemontools-style

chkservice /{run,var,etc}/service-bundles/{services,targets}/* /var/local/sv/*

Display the statuses of all (standard location) service bundles, in a full screen TUI scrollable table.

svstat /var/service-bundles/services/gcron

Print the status of the cron service, in human readable short form.

svstat --long /var/service-bundles/services/gcron

Print the status of the cron service, in human readable long form.

svc -u /var/service-bundles/services/gcron

Start the cron service, ignoring dependency and conflict information.

svc -d /var/service-bundles/services/gcron

Stop the cron service.

svc -o /var/service-bundles/services/gcron

Run the service at least once, starting it if it is not already started.

svc -O /var/service-bundles/services/gcron

Run the service at most once, not starting it if it is not already started.

svc -a /var/service-bundles/services/gcron

Send an ALRM signal to the cron service. This is used, for example, to tell logging services to cycle to a new log file.

svc -t /var/service-bundles/services/gcron

Send a TERM signal to the cron service.

svc -T /var/service-bundles/services/gcron

Send a TERM signal to only the "main" process of the cron service.

svc -k /var/service-bundles/services/gcron

Send a KILL signal to the cron service.

svc -K /var/service-bundles/services/gcron

Send a KILL signal to only the "main" process of the cron service.

svc -h /var/service-bundles/services/gcron

Send a HUP signal to the cron service.

svc -H /var/service-bundles/services/gcron

Send a HUP signal to only the "main" process of the cron service.

svshow /var/service-bundles/services/gcron

Emit a machine-parseable status of the cron service. Use the --json option for an alternative machine-parseable form.

OpenBSD-style

rcctl get cron

Print the variables set by the conventional env/ environment directory for the cron service.

rcctl set cron flags --wibble

Set the flags variable, set by the conventional env/ environment directory for the cron service, to --wibble.

rcctl status cron

Print long form human-readable status of the cron service. This also prints the tail of any associated log, if it is in the conventional place.

rcctl start cron

Start the cron service, following any dependencies.

rcctl stop cron

Stop the cron service.

rcctl enable cron

Set the cron service to auto-start at bootstrap.

rcctl disable cron

Set the cron service to not auto-start at bootstrap.

systemd-style

system-control status cron

Print long form human-readable status of the cron service. This also prints the tail of any associated log, if it is in the conventional place.

system-control start cron

Start the cron service, following any dependencies.

system-control stop cron

Stop the cron service.

system-control preset cron

Set the cron service to auto-start at bootstrap or not, according to administrator-supplied and package-supplied preset information.

system-control reset cron

Start or stop the cron service according to its enable/disable state, i.e. reset to the configured bootstrap state.

system-control enable cron

Set the cron service to auto-start at bootstrap.

system-control disable cron

Set the cron service to not auto-start at bootstrap.

system-control condrestart cron

Send a TERM signal to restart the cron service.

system-control hangup ttylogin@vc1-tty

Send a HUP signal to the session leader/main process of the ttylogin@vc1-tty service.

system-control cat cron

Print the contents of the various run, restart, and so forth programs of the cron service.

system-control poweroff

Immediately run the system power-off procedure, shutting down any services configured to shut down at power off.

system-control print-service-env cron

Print the variables set by the conventional env/ environment directory for the cron service.

system-control set-service-env cron flags --wibble

Set the flags variable, set by the conventional env/ environment directory for the cron service, to --wibble.

Solaris SMF-style

svcadm enable cron

Start (sic!) the cron service.

svcadm disable cron

Stop (sic!) the cron service.

Common

setfacl -m u:jim:rx /var/service-bundles/services/gcron{,/log}/supervise
setfacl -m u:jim:rw /var/service-bundles/services/gcron{,/log}/supervise/ok
setfacl -m u:jim:r /var/service-bundles/services/gcron{,/log}/supervise/status

On systems where these are not world-accessible, grant the user jim access to read the status of the cron service and its associated log service.

shutdown -r -g 30

After a grace period of 30 minutes, during which messages will be broadcast to logged-on users, run the system reboot procedure, shutting down any services configured to shut down at power off.