[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Commands service and systemctl.



On 14/04/2023 22:05, peter wrote:

https://en.wikipedia.org/wiki/Systemd has many occurrences of
"service", none referring to the service command.

See systemd.unit(5). Besides services, systemd has sockets, timers and
other unit types.

For several somethings, the result of command,
service something COMMAND
approximates the result of
systemctl COMMAND something.service
although systemctl might be more powerful.

Systemd may generate service units for scripts in /etc/init.d that do
not have their .service files. When systemd is running than the service
command should delegate operation to systemd that tracks states of
system services. So systemctl is native and more powerful in such case.

When SysV init is used than systemctl is not available. There are
even more subtle cases:

https://www.debian.org/doc/manuals/debian-handbook/unix-services.en.html
The Debian Administrator's Handbook
Chapter 9. Unix Services
9.1.2. The System V init system
DEBIAN POLICY Restarting services

The maintainer scripts for Debian packages will sometimes restart
certain services to ensure their availability or get them to take
certain options into account. The command that controls a service —
service service operation — doesn't take runlevel into consideration,
assumes (wrongly) that the service is currently being used, and may thus
initiate incorrect operations (starting a service that was deliberately
stopped, or stopping a service that is already stopped, etc.). Debian
therefore introduced the invoke-rc.d program: this program must be used
by maintainer scripts to run services initialization scripts and it will
only execute the necessary commands. Note that, contrary to common
usage, the .d suffix is used here in a program name, and not in a
directory.

A specific init script might support operation that systemd is not aware of. I do think that you are fighting with portability issues, so use tool native to running init system.



Reply to: