服务所在路径:
系统(/user/lib/systemd/system/)
用户(/etc/lib/systemd/user/)
创建服务示例:
[Unit]
Description=MySQL Community Server
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=mysql.service
[Service]
User=mysql
Group=mysql
# Execute pre and post scripts as root
PermissionsStartOnly=true
# Needed to create system tables etc.
ExecStartPre=/usr/bin/mysql-systemd-start pre
# Start main service
ExecStart=/usr/bin/mysqld_safe --basedir=/usr
# Don't signal startup success before a ping works
ExecStartPost=/usr/bin/mysql-systemd-start post
# Give up if ping don't get an answer
TimeoutSec=600
Restart=always
PrivateTmp=false
[Unit]
Description=Postfix Mail Transport Agent
After=syslog.target network.target
[Service]
Type=simple
KillMode=none
SendSIGKILL=no
RemainAfterExit=true
# /etc/init.d/下面保存许多系统服务的启动和停止脚本
ExecStart=-/etc/init.d/postfix start
ExecStop=-/etc/init.d/postfix stop
[Install]
WantedBy=multi-user.target