CENTOS7 下编辑开机自启
新增命令命令文件,以redis为例,启动命令为
redis-server.service
vi /usr/lib/systemd/system/redis-server.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStop=/usr/libexec/redis-shutdown
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
编辑之后保存,
systemctl daemon-reload
systemctl enable redis-server
如果报Failed to execute operation: File exists
systemctl disable redis-server