Welcome to ROSMASTER M3 PRO repository
19.Customized service management
19.Customized service management
This course takes the newly created OLED startup service as an example for reference only to the service management process. The Yahboom Muto image has been set up to start the oled service automatically at boot.
1. Create a new service file
Create a new yahboom_oled.service in the user directory
touch yahboom_oled.servicevim yahboom_oled.service
Add the following content, where User represents the user name and needs to be modified according to the actual user name;
ExecStart represents the command to be executed and the command needs to be executed according to the actual modification.
Jetson nano system service files:
x[Unit]Description=yahboom_oled start serviceAfter=multi-user.target[Service]Type=idleUser=jetsonExecStart=/bin/sh -c "python3 /home/jetson/software/oled_yahboom/yahboom_oled.py"WorkingDirectory=/home/jetson[Install]WantedBy=multi-user.target
Raspberry Pi system service file:
xxxxxxxxxx[Unit]Description=yahboom_oled start serviceAfter=multi-user.target[Service]Type=idleUser=piExecStart=/bin/sh -c "python3 /home/pi/software/oled_yahboom/yahboom_oled.py"WorkingDirectory=/home/pi[Install]WantedBy=multi-user.target
Then exit editing and enter: qw to save the file.
2. Update service
Copy the newly created yahboom_oled.service service file to the /etc/systemd/system/ path.
xxxxxxxxxxsudo cp yahboom_oled.service /etc/systemd/system/
Update system services
xxxxxxxxxxsudo systemctl daemon-reload
3. Management services
Check service status
xxxxxxxxxxsudo systemctl status yahboom_oled.service
Start service
xxxxxxxxxxsudo systemctl start yahboom_oled.service
Restart service
xxxxxxxxxxsudo systemctl restart yahboom_oled.service
Set the service to automatically start at boot
xxxxxxxxxxsudo systemctl enable yahboom_oled.service
Close service
xxxxxxxxxxsudo systemctl stop yahboom_oled.service
Service does not start when booting
xxxxxxxxxxsudo systemctl disable yahboom_oled.service