模仿服务来实现开机自启动
在/etc/systemd/system/目录下创建一个叫做ngrok.service的文件
写入以下代码:
[Unit]
Description=ngrok
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/ngrok -config=/root/ngrok/ngrok.conf start pan-ssh pi-ssh mac-ssh pi-vnc pan-http pi-http bt-http test-http # 这一行是启动命令,适用于其他命令
[Install]
WantedBy=multi-user.target
使用方法:
运行ngroksystemctl
start ngrok
查询ngrok的运行状态
systemctl status ngrok
实现开机自启动ngrok
systemctl enable ngrok