Книга: Fedora™ Unleashed, 2008 edition

Use /usr/sbin/ftpshut to Schedule FTP Server Downtime

Use /usr/sbin/ftpshut to Schedule FTP Server Downtime

As with any public server administration, it is always good practice to let users of the FTP server know about upcoming outages, when the server will be updated, and other relevant site information. The ftpshut command allows the administrator to let the FTP server do much of this automatically.

The ftpshut command enables the administrator to take down the FTP server at a specific time, based on some parameters passed to it. The format of the command is as follows and is documented in the ftpshut man page:

ftpshut [ -V ] [ -l min] [ -d min] time [ warning-message ... ]

The -V parameter displays the command's version information. The time parameter is the time when the ftpshut command will stop the FTP servers. This parameter takes either a + number for the number of minutes from the current time, or a specific hour and minute in 24-hour clock format with the syntax of HH:MM.

The -l parameter enables the FTP server administrator to specify how long, in minutes, before shutdown the server disallows new connections. The default is 10 minutes. If the time given to shut down the servers is less than 10 minutes, new connections are disallowed immediately.

The -d parameter is similar to the -l parameter, but controls when the FTP server terminates the current connections. By default, this occurs five minutes before the server shuts down. If the shutdown time is less than five minutes, the server terminates the current connections immediately.

When you execute this command, the FTP server creates a file containing the shutdown information in the location specified under the shutdown section in the ftpaccess file. The default configuration for this file is /etc/shutmsg. If you execute the ftpshut command with warning messages, the messages are displayed when the user logs in to the server.

Name (pheniox:tdc): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230-system doing down at Mon Sep 3 06:23:00 2001
230-0 users of unlimited on pheniox.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.

Here is a sample ftpshut command:

ftpshut -l 5 -d 5 +10 "system going down at %s %N users of %M on %R"

This command tells the FTP server to disconnect new connections in 5 minutes, drop all current connections in 5 minutes, shut down the server in 10 minutes, and display a warning message to the users at login. The message can be a mixture of text and the magic cookies defined in Table 20.4. It is important to keep in mind that the message can be a maximum of 75 characters in length. Additionally, it is not important to know how many characters the magic cookies take because the system knows this information and truncates the message at 75 characters.

TABLE 20.4 Magic Cookies for the ftpshut Command

Cookie Description
%s Time the system will be shut down
%r Time new connections will be denied
%d Time current connections will be dropped
%C Current working directory
%E Server administrator's email address as specified in the ftpaccess file
%F Available free space in the current working directories partition, in kilobytes
%L Local host time
%M Maximum number of allowed connections in this user class
%N Current number of connections for this user class
%R Remote hostname
%T Local time, in the form of Fri Aug 31 21:04:00 2001
%U Username given at login

When ftpshut is issued to the system, it creates a file that stores the necessary information. The ftprestart command removes this file for all servers, either canceling the impending shutdown or removing the shutdown file and restarting the FTP server. The ftprestart has only one optional argument, -V, to show version information.

Оглавление книги


Генерация: 0.049. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз