LinuxCommandLibrary

runsvchdir

Change the active runit service directory

TLDR

Switch runsvdir directories

$ sudo runsvchdir [path/to/directory]
copy

SYNOPSIS

runsvchdir pid service_dir

PARAMETERS

pid
    The process ID of the runsv process to affect.

service_dir
    The directory of the service. runsvchdir will change the runsv process's current working directory to service_dir.

DESCRIPTION

The runsvchdir command changes the current working directory of a runsv process to the specified service directory. This is primarily intended for internal use by runit and associated utilities. It's commonly used in service management scripts to ensure that the runsv process operates within the correct directory context. Using runsvchdir allows scripts to perform actions related to a specific service (such as starting, stopping, or restarting) without needing to hardcode or manually track the service's directory. It is generally used by the runsv process itself, but it can also be employed by administrators or scripts that need to manage runit services programmatically. runsvchdir simplifies service management by encapsulating the directory context switch within a single command.

The command interacts with the process ID provided as argument.

CAVEATS

Improper use can lead to unexpected behavior or service disruption. Requires sufficient privileges to affect the target process.

EXIT STATUS

The runsvchdir command exits with 0 on success. It exits with 1 if it can't find the process specified, with 2 if it can't change directory, and with 111 on other errors.

SECURITY

Using runsvchdir usually requires root privileges. Make sure any script using runsvchdir is secured. Avoid using it to processes which do not belong to runit.

HISTORY

runsvchdir is a utility specific to the runit init system, created by Gerrit Pape. It was developed as an integral part of runit to facilitate robust and simple service management, especially the reliable changing of process directories for service management. It's usage grows with runit usage.

SEE ALSO

runsv(8), runit(8), sv(8), chpst(1)

Copied to clipboard