在CentOS上,您可以使用systemd服务来实现vsftpd的自动重启。请按照以下步骤操作:
sudo yum install vsftpd
sudo vi /etc/systemd/system/vsftpd.service
[Unit]
Description=The vsftpd FTP server
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
保存并关闭文件。
重新加载systemd配置以识别新创建的服务:
sudo systemctl daemon-reload
sudo systemctl enable vsftpd.service
sudo systemctl start vsftpd.service
sudo systemctl status vsftpd.service
现在,vsftpd已配置为在CentOS上自动重启。如果服务失败,它将在42秒后自动尝试重新启动。