CentOS8_将PureFTPd添加为标准系统服务
备注:这是在 CentOS8_PureFTPd虚拟用户验证 的基础上进行的。
目的:开机自动运行PureFTPd服务,并使用自定义的方式启动和关闭PureFTPd服务
创建脚本:
[root@centos8 ~]# cat pure-ftpd.sh
#!/bin/bash
#### 2020.1.1 by zhuohua. ####
# chkconfig: 35 90 10
# description: PureFTPd.
case "$1" in
start)
/usr/local/pureftpd/sbin/pure-ftpd /usr/local/pureftpd/etc/pure-ftpd.conf
;;
stop)
killall -9 pure-ftpd
;;
status)
pgrep -l pure-ftpd &> /dev/null
;;
*)
echo "Usage: $0 {start|stop|status}"
esac
exit 0
将PureFTPd添加为标准系统服务:
[root@centos8 ~]# cp pure-ftpd.sh /etc/init.d/pure-ftpd
[root@centos8 ~]# chmod a+x /etc/init.d/pure-ftpd
[root@centos8 ~]# ll /etc/init.d/pure-ftpd
-rwxr-xr-x. 1 root root 313 10月 10 16:38 /etc/init.d/pure-ftpd
[root@centos8 ~]# chkconfig --add pure-ftpd
[root@centos8 ~]# systemctl is-enabled pure-ftpd
pure-ftpd.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install is-enabled pure-ftpd
enabled
测试:
[root@centos8 ~]# systemctl stop pure-ftpd
[root@centos8 ~]#
[root@centos8 ~]# pgrep -l pure-ftpd
[root@centos8 ~]# echo $?
1
[root@centos8 ~]#
[root@centos8 ~]# ps -ef |grep pure-ftpd |grep -v grep
[root@centos8 ~]# echo $?
1
[root@centos8 ~]# systemctl status pure-ftpd
● pure-ftpd.service - SYSV: PureFTPd.
Loaded: loaded (/etc/rc.d/init.d/pure-ftpd; generated)
Active: failed (Result: signal) since Sat 2020-10-10 16:44:01 CST; 1min 51s ago
Docs: man:systemd-sysv-generator(8)
Process: 1695 ExecStop=/etc/rc.d/init.d/pure-ftpd stop (code=killed, signal=KILL)
Process: 1687 ExecStart=/etc/rc.d/init.d/pure-ftpd start (code=exited, status=0/SUCCESS)
[root@centos8 ~]# systemctl start pure-ftpd
[root@centos8 ~]#
[root@centos8 ~]# pgrep -l pure-ftpd
1746 pure-ftpd
[root@centos8 ~]# echo $?
0
[root@centos8 ~]#
[root@centos8 ~]# ps -ef |grep pure-ftpd |grep -v grep
root 1746 1 0 16:46 ? 00:00:00 /usr/local/pureftpd/sbin/pure-ftpd /usr/local/pureftpd/etc/pure-ftpd.conf
[root@centos8 ~]# echo $?
0
[root@centos8 ~]# systemctl status pure-ftpd
● pure-ftpd.service - SYSV: PureFTPd.
Loaded: loaded (/etc/rc.d/init.d/pure-ftpd; generated)
Active: active (running) since Sat 2020-10-10 16:46:35 CST; 50s ago
Docs: man:systemd-sysv-generator(8)
Process: 1695 ExecStop=/etc/rc.d/init.d/pure-ftpd stop (code=killed, signal=KILL)
Process: 1744 ExecStart=/etc/rc.d/init.d/pure-ftpd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 11298)
Memory: 932.0K
CGroup: /system.slice/pure-ftpd.service
└─1746 /usr/local/pureftpd/sbin/pure-ftpd /usr/local/pureftpd/etc/pure-ftpd.conf
笺注:系统重启后,PureFTPd服务会自动启动的了
相关文章:
CentOS8_PureFTPd修改端口 |