onns@onns-desktop:/etc/systemd/system$ systemctl start ngrok.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'ngrok.service'. Authenticating as: onns,,, (onns) Password: ==== AUTHENTICATION COMPLETE === Warning: The unit file, source configuration file or drop-ins of ngrok.service changed on disk. Run 'systemctl daemon-reload' to reload units.
需要密码验证,然后有一句特殊提示:
Warning: The unit file, source configuration file or drop-ins of ngrok.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
所以其实要重新加载一下(因为你毕竟添加了一个service):
1 2 3 4 5 6
onns@onns-desktop:/etc/systemd/system$ systemctl daemon-reload ==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon === Authentication is required to reload the systemd state. Authenticating as: onns,,, (onns) Password: ==== AUTHENTICATION COMPLETE ===
然后就可以开启服务了:
1 2 3 4 5 6
onns@onns-desktop:/etc/systemd/system$ systemctl start ngrok.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to start 'ngrok.service'. Authenticating as: onns,,, (onns) Password: ==== AUTHENTICATION COMPLETE ===
然后查看这个服务的状态:
1 2 3 4 5 6 7 8 9 10
onns@onns-desktop:/etc/systemd/system$ systemctl status ngrok.service ● ngrok.service - ngrok Loaded: loaded (/etc/systemd/system/ngrok.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-12-14 18:31:42 CST; 30min ago Main PID: 37616 (ngrok) Tasks: 6 (limit: 8967) CGroup: /system.slice/ngrok.service └─37616 /home/onns/Desktop/ngrok -config /home/onns/Desktop/ngrok.cfg start win ssh
12月 14 18:31:42 onns-desktop systemd[1]: Started ngrok.
博客的代码是没有颜色的,可以凑合着看一下。
然后最重要的一步是开启开机启动:
1 2 3 4 5 6 7 8 9 10 11
onns@onns-desktop:/etc/systemd/system$ systemctl enable ngrok.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files === Authentication is required to manage system service or unit files. Authenticating as: onns,,, (onns) Password: ==== AUTHENTICATION COMPLETE === ==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon === Authentication is required to reload the systemd state. Authenticating as: onns,,, (onns) Password: ==== AUTHENTICATION COMPLETE ===