设置命令为systemctl管理 开机自启

  1. 添加systemd配置文件:
vim /usr/lib/systemd/system/程序名.service

文件内容如下:

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=这里写绝对路径程序的启动命令,例如 /usr/local/程序 -c /usr/local/程序配置文件
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit

[Install]
WantedBy=multi-user.target
  1. 设置开机启动
systemctl daemon-reload     # 重新加载配置服务 

systemctl enable 程序名 # 程序名为设置server文件的名字 
  1. 启动 程序
systemctl start 程序

猜你喜欢

转载自blog.csdn.net/qq_26129413/article/details/112919390