centos 7 创建启动脚本

创建启动脚本

[root@ALIYUN-64 /]# vim /etc/systemd/system/frp.service

[Unit]
Description=frp server  #描述信息

[Service]
TimeoutStartSec=0 
ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini #需要执行的命令

[Install]
WantedBy=multi-user.target #运行的级别

设置为开机启动

[root@ALIYUN-64 system]# systemctl enable frp
Created symlink from /etc/systemd/system/multi-user.target.wants/frp.service to /etc/systemd/system/frp.service.    

重启服务

[root@ALIYUN-64 frp]# systemctl restart frp

查看状态

[root@ALIYUN-64 frp]# systemctl status frp
● frp.service - frp server
   Loaded: loaded (/etc/systemd/system/frp.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-05-11 14:20:42 CST; 3s ago
 Main PID: 3399 (frps)
   CGroup: /system.slice/frp.service
           └─3399 /usr/local/frp/frps -c /usr/local/frp/frps.ini

May 11 14:20:42 ALIYUN-64 systemd[1]: Started frp server.
May 11 14:20:42 ALIYUN-64 systemd[1]: Starting frp server...
May 11 14:20:42 ALIYUN-64 frps[3399]: 2017/05/11 14:20:42 [main.go:194] [I] Start frps success
May 11 14:20:42 ALIYUN-64 frps[3399]: 2017/05/11 14:20:42 [main.go:196] [I] PrivilegeMode is enabled, you shoul...issues
Hint: Some lines were ellipsized, use -l to show in full.