How to Manage SystemD Processes in Userspace

Gewijzigd op Ma, 22 Dec om 9:59 AM

How to Manage SystemD Processes in Userspace

System processes like php-fpm, redis and varnish that run under the user account can be managed using systemctl.


You can also list and restart services using our command line tool mnage.
For all mnage options check the mnage page.

Using Systemctl

# check the status of a service
systemctl status php-fpm@8.3 
# reload services
systemctl reload php-fpm@8.3 
# restart a service
systemctl restart php-fpm@8.3

Using Journalctl

You can use journalctl to check on processes running under your account.

# To view logs from a specific date (in YYYY-MM-DD format), use:
journalctl --since="2022-03-01 00:00:00"

# To follow the log (useful for long running services), use:
journalctl -f

# If you know the name of a systemd unit, you can view its logs with:
journalctl -u ${SERVICE}

Using Systemctl in Scripts

You can also use systemctl in scripts.

# Get your user id
export XDG_RUNTIME_DIR="/run/user/$(id -u)"

# Run systemctl as the user.
systemctl --user restart ${SERVICE}
systemctl --user reload ${SERVICE}

Was dit artikel nuttig?

Dat is fantastisch!

Hartelijk dank voor uw beoordeling

Sorry dat we u niet konden helpen

Hartelijk dank voor uw beoordeling

Laat ons weten hoe we dit artikel kunnen verbeteren!

Selecteer tenminste een van de redenen
CAPTCHA-verificatie is vereist.

Feedback verzonden

We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren