Ubuntu service开机自启设置

📅 2026/7/8 3:27:16
Ubuntu service开机自启设置
1、将 这个 test.service文件放到 /etc/systemd/system/目录下2、执行下面指令开启开机自启sudo systemctl daemon-reload # 让 systemd 重新读取新 unit sudo systemctl enable test.service # 设置开机自启 sudo systemctl restart test.service # 立刻启动3、关闭开机自启sudo systemctl stop test sudo systemctl disable test.service4、下次开机就不会有这个了5、sudo systemctl 常见指令sudo systemctl stop 服务名命令效果disable取消开机自启不停止当前进程stop立刻停止当前进程不影响开机自启设置disable --now同时 disable stop取消自启并立刻停掉enable重新设置开机自启恢复 wants 链接restart重启当前服务与 enable/disable 无关