示例
假如要启动的命令是
/usr/local/frp/frps -c /usr/local/frp/frps.ini
生成启动文件
nano /etc/init.d/frps
#!/bin/sh
### BEGIN INIT INFO
# Provides: frps
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: frps
# Description:
#
### END INIT INFO
NAME=frps
DAEMON=/usr/local/frp/$NAME
CONFIG=/usr/local/frp/$NAME.ini
case "$1" in
start)
echo "Starting $NAME..."
nohup $DAEMON -c $CONFIG >/dev/null 2>&1 &
;;
stop)
echo "Stopping $NAME..."
sudo ps -ef|grep $NAME|grep -v grep|cut -c 9-15|xargs kill -9
;;
restart)
$0 stop && sleep 2 && $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
赋权并且设置自启动
赋权
chmod 777 frps
设置自启动
chkconfig frps on
启动
service frps start
评论 (0)