vi /etc/systemd/system/xxx.service
[Unit] Description=My Screen Session After=network.target [Service] Type=forking ExecStart=/usr/bin/screen -dmS mysession /bin/bash -c 'your_command_here' ExecStop=/usr/bin/screen -S mysession -X quit Restart=on-failure [Install] WantedBy=multi-user.target
your_command_here 输入你自己要执行的命令
sudo systemctl daemon-reload
sudo systemctl enable xxx.service
设置成功与否
sudo systemctl is-enabled xxx.service
手动开启下:
systemctl strat xxx
查看状态
systemctl status xxx
浙公网安备 33010602011771号