I want to add a feature to a project that auto starts a service.
My service file contains:
[Unit] Description=example Server After=network.target [Service] Type=idle ExecStart=/opt/xxx/xxx/sample.sh Restart=always RestartSec=3 [Install] WantedBy=multi-user.target
The steps I follow are:
systemctl enable sample
systemctl start sample
service sample status, which shows my service is running...
I want to auto start the service if it crashes or stops.
When I stop my service using
systemctl stop sample, it doesn't autostart. Any idea how to achive this?