You can find out what systemd reload nginx
will do by looking at the ExecReload=
option in the [Service]
section in the nginx.service
unit file (located at /usr/lib/systemd/system/nginx.service
on my system):
$ systemctl cat nginx | grep ExecReload=
Or by running:
$ systemctl show nginx.service --property=ExecReload
On my system, I get:
ExecReload=/usr/bin/kill -HUP $MAINPID
From nginx(8)
:
-s signal Send a signal to the master process. The argument signal
can be one of: stop, quit, reopen, reload. The following
table shows the corresponding system signals:
stop SIGTERM
quit SIGQUIT
reopen SIGUSR1
reload SIGHUP
Thus systemctl reload nginx
and nginx -s reload
will, almost, do the same thing.
The differences are:
systemctl reload nginx
will execute the command in a clean environment (and not the current user environment);
systemctl reload
works for any service that allows it (which has it configured in the unit file). No need to remember service specific commands. This is even more interesting if you have several instances of a service.
Using service
or init.d
scripts are legacy/deprecated ways of doing the same thing. Although they might work, they are not supported nor recommended anymore on a systemd based system.
1Actually if your system supports it, I would prefer using
service
orinit.d
, likesudo service nginx reload
– Mohammad AbuShady – 2014-02-11T14:50:34.827