コマンドを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