Senior
How to start a service in the system (systemd)?
sobes.tech AI
Answer from AI
To start a service in a systemd system, follow these steps:
- Create a service unit file, for example
/etc/systemd/system/myservice.service, with the following content:
[Unit]
Description=My Service
After=network.target
[Service]
ExecStart=/usr/bin/myservice
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Reload the systemd configuration:
sudo systemctl daemon-reload
- Start the service:
sudo systemctl start myservice
- (Optional) Enable auto-start on boot:
sudo systemctl enable myservice
- Check the service status:
sudo systemctl status myservice
Thus, systemd manages the starting, stopping, and monitoring of services in the system.