« Back to Systemd: Frequently Asked Questions

How to reload or restart a systemd service?

How to reload or restart a systemd service?

Use the systemctl command with the 'reload' or 'restart' subcommand, followed by the service.

Systemd service units can be restarted with systemctl. There are three subcommands available to restart a service:

  1. reload
  2. restart
  3. reload-or-restart
  4. try-reload-or-restart

Reload: systemctl reload

Some services support reloading its configuration, typically without the need to fully restart. For example, a web server service like nginx does support this. In this case, a simple reload is enough.

systemctl reload nginx.service

Not sure if a reload is possible? With subcommand show we can query the relevant property ExecReload from a service.

# systemctl show --property ExecReload --value nginx.service
{ path=/bin/kill ; argv[]=/bin/kill -s HUP $MAINPID ; ignore_errors=no ; start_time=[Mon 2024-12-09 04:31:45 EST] ; stop_time=[Mon 2024-12-09 04:31:45 EST] ; pid=4050588 ; code=exited ; status=0 }

Restart: systemctl restart

If reloading is not enough, or the service does not support it, then a restart is required. This will effectively stop and start the service unit.

systemctl restart nginx.service

Reload or restart

A hybrid option is to first reload the service. If that is not supported, then the service will be instructed to do a normal restart. This is achieved using the reload-or-restart subcommand.

systemctl reload-or-restart nginx.service

Try a reload or restart

For scripting purposes, the try-reload-or-restart subcommand will attempt to take the reload and restart action. If the service is not running, then no action will be performed.

systemctl try-reload-or-restart nginx.service

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to Systemd

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon