在Ubuntu中,要配置systemd服务自启动,可以按照以下步骤操作:
.service
为扩展名,比如my_service.service
。[Unit]
Description=My Service
After=network.target
[Service]
Type=simple
ExecStart=/path/to/your/service
Restart=always
User=your_username
[Install]
WantedBy=multi-user.target
/etc/systemd/system/
目录下。sudo systemctl daemon-reload
sudo systemctl enable my_service.service
sudo systemctl start my_service.service
这样,你的服务就会在系统启动时自动启动。你也可以通过sudo systemctl status my_service.service
命令查看服务的状态。