- Linux Administration Cookbook
- Adam K. Dean
- 110字
- 2021-07-02 14:24:42
How it works...
When you instruct systemd to start or stop a unit, what you're actually doing is running the ExecStart or ExecStop portions of its unit file.
Taking postfix as our example, its unit file looks like this:
# /usr/lib/systemd/system/postfix.service
[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network.target
Conflicts=sendmail.service exim.service
[Service]
Type=forking
PIDFile=/var/spool/postfix/pid/master.pid
EnvironmentFile=-/etc/sysconfig/network
ExecStartPre=-/usr/libexec/postfix/aliasesdb
ExecStartPre=-/usr/libexec/postfix/chroot-update
ExecStart=/usr/sbin/postfix start
ExecReload=/usr/sbin/postfix reload
ExecStop=/usr/sbin/postfix stop
[Install]
WantedBy=multi-user.target
Here we can see that, when we issue a systemctl start postfix command, it's literally running the postfix binary with the start option. The opposite is true for stop.
We also have some ExecStartPre lines, which are commands executed before the main ExecStart command is run.