• 周六. 10 月 5th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Linux uses systemctl to register system services

King Wang

1 月 3, 2022

1. New service file

For example, we build new buildings frp Service documents of , Then the service name is frp.service

2. Input content

[Unit]
# The service description 
Description=Frp Client Service
# Requires that the network must be executed 
Requires=network-online.target
# Start after the network starts 
After=network.target
[Service]
Type=simple
# Run the user 
User=nobody
# Restart mode 
Restart=always
# Carry out orders 
ExecStart=/usr/bin/frpc -c /etc/frp/frpc.ini
# Reload the configuration file 
ExecReload=/usr/bin/frpc reload -c /etc/frp/frpc.ini
[Install]
WantedBy=multi-user.target

It’s mainly about setting up ExecStart This is the script command for the service ,ExecReload This is the reload file command , It’s ok if there’s any ,Restart It means that on-failure Restart on ,RestartSec every other 5s Restart once

3. Moving files

Put this file frp.service Move to /lib/systemd/system/frp.service below

4. operation

Register system services

systemctl enable frp.service

Turn on

systemctl start frp.service

Check the status

systemctl status frp.service

When it appears, the following indicates that the operation is successful

close

systemctl stop frp.service

发表回复