Ubuntu20.04 开机启动服务

1、编写开机自启脚本

1 cd /etc/systemd/system
2 sudo vim hello.service

脚本内容:

[Unit]
Description=hello

[Service]
Type=simple
ExecStart=/mnt/data1/hello/loong
Restart=always
[Install]
WantedBy=multi-user.target

2、启动

sudo systemctl start hello.service

  

3、修改配置文件后需要重加载配置

sudo systemctl daemon-reload

  

4、开机启动

systemctl enable hello.service

  

5、查看实时日志

sudo journalctl -f -u hello.service

  

 

posted @ 2023-10-31 13:16  Pynix  阅读(134)  评论(0编辑  收藏  举报