Linux ftpshut Command
The Linux ftpshut command shuts down the FTP server at a specified time.
ftpshutIt allows the system administrator to shut down the FTP service at a specified time and send warning messages to connected FTP users before shutdown.
This command is commonly used for system maintenance, upgrades, or other scenarios where the FTP service needs to be temporarily stopped.
code>ftpshutIf the shutdown time is set to "none", the server will be shut down immediately. If the "+30" format is used, it means the server will be shut down after 30 minutes. If the "1130" format is used, it means the server will be shut down at 11:30 daily, using a 24-hour time format.
After the FTP server is shut down, a file named shutmsg is generated in the /etc directory. Deleting it will re-enable the FTP server functionality.
Syntax
ftpshut [选项] [时间] [警告消息]
Parameters:
Time: Specifies the time when the FTP service will be shut down. The time can be in
+minutesformat (for example+10means shutdown after 10 minutes), or inHHMMformat (for example1430means shutdown at 2:30 PM).Warning message: The warning message sent to all connected FTP users before the FTP service is shut down. The message content can contain the following placeholders:
%s: Indicates the time when the FTP service will be shut down.%r: Indicates the time when the FTP service will restart after shutdown.%d: Indicates the remaining time (in minutes) before the FTP service is shut down.
Common options:
-l <分钟>: Specifies the time (in minutes) before the FTP service shutdown to reject new user logins.-d <分钟>: Specifies the time (in minutes) before the FTP service shutdown to disconnect all user connections.
Examples
To shut down the FTP server at 11:00 PM, reject new FTP logins 5 minutes before shutdown, close all FTP connections 3 minutes before shutdown, and send a warning message, use the following command:
ftpshut-d 3 -1 5 1100 "Server will be shutdown at 23:00:00"
Suppose you want to shut down the FTP service after 10 minutes and send a warning message to users; you can use the following command:
ftpshut +10 "FTP 服务将在 %s 关闭,请尽快完成操作。"
In this example,+10specifies that the FTP service will be shut down after 10 minutes,"FTP 服务将在 %s 关闭,请尽快完成操作。"is the warning message sent to users,%swill be replaced with the actual shutdown time.
If you want to shut down the FTP service at 3:00 PM, you can use the following command:
ftpshut 1500 "FTP 服务将在 %s 关闭,预计在 %r 重新启动。"
In this example,1500specifies that the FTP service will be shut down at 3:00 PM,"FTP 服务将在 %s 关闭,预计在 %r 重新启动。"is the warning message sent to users,%sand%rwill be replaced with the actual shutdown time and restart time.
If you want to reject new user logins 5 minutes before the FTP service shuts down, you can use the following command:
ftpshut -l 5 +10 "FTP 服务将在 %s 关闭,请尽快完成操作。"
In this example,-l 5specifies that new user logins will be rejected 5 minutes before shutdown,+10specifies that the FTP service will be shut down after 10 minutes.
If you want to disconnect all users 2 minutes before the FTP service shuts down, you can use the following command:
ftpshut -d 2 +10 "FTP 服务将在 %s 关闭,请尽快完成操作。"
In this example,-d 2specifies that all users will be disconnected 2 minutes before shutdown,+10specifies that the FTP service will be shut down after 10 minutes.
Notes
ftpshutThe command is usually used together with theftpwhocommand,ftpwhowhich can be used to view currently connected FTP users.- After using
ftpshutto shut down the FTP service, if you need to restart it, you can use theservice vsftpd restartorsystemctl restart vsftpdcommand (the specific command depends on your FTP server software and system configuration). ftpshutThe command is commonly used withvsftpdorproftpdand other FTP server software; actual support may vary depending on the FTP server software.