要在Ubuntu上实现VSFTPD的自动重启,您可以使用systemd服务。请按照以下步骤操作:
sudo apt-get update
sudo apt-get install vsftpd
vsftpd.service的新文件:sudo nano /etc/systemd/system/vsftpd.service
[Unit]
Description=VSFTPD FTP Server
After=network.target
[Service]
Type=simple
User=ftp
Group=ftp
ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
这个服务文件定义了VSFTPD服务的描述、启动顺序、运行用户、执行命令等。
保存并关闭文件。
重新加载systemd守护进程以识别新创建的服务:
sudo systemctl daemon-reload
sudo systemctl enable vsftpd
sudo systemctl start vsftpd
sudo systemctl stop vsftpd
sudo systemctl restart vsftpd
sudo systemctl status vsftpd
现在,VSFTPD服务将在Ubuntu系统启动时自动运行,并在出现故障时自动重启。