Euler system adds self-starting service

1. Create a service file with the suffix .service

For example your_service.service, and open that file with a text editor:
sudo vim /etc/systemd/system/your_service.service
Replace your_service with the name of your service.

2. Add the following to the service file

(Pay attention to replace the service name, description, execution path and command):

[Unit]
  Description=Your Service Description

[Service]
   ExecStart=/path/to/your/command

[Install]
   WantedBy=multi-user.target

Replace Your Service Description with a description of your service.
Replace /path/to/your/command with the actual execution path and command of your service.

3. Save and close the file

4. Enable the service

sudo systemctl enable your_service.service
Replace your_service with the name of your service.

5. Start the service

sudo systemctl start your_service.service
Replace your_service with the name of your service.

6. Verify that the service is running

sudo systemctl status your_service.service
Replace your_service with the name of your service.

7. If the service is running normally, restarting the system will automatically start the service

sudo reboot
If the service is not running properly, check the syslog for more information:
sudo journalctl -u your_service.service
Replace your_service with the name of your service.

== Note that the above steps assume you are using systemd, the default service manager for Euler systems. If you are using another service manager, such as init.d, you will need to adjust the steps accordingly. ==

Guess you like

Origin blog.csdn.net/wyw0000/article/details/132061012