flush Command in Linux



The Postfix flush service in Linux manages deferred mail delivery. It attempts to deliver emails that have been deferred. The deferred emails are unsent emails held due to the destination server's reachability issue.

The flush service maintains a record of deferred emails by destination. It is useful to improve the performance of SMTP ETRN requests, and its command-line equivalent sendmail -qR or postqueue -f.

Table of Contents

Here is a comprehensive guide to the options available with the flush command −

Requests Implemented by flush Service

The requests the flush service implements are listed below −

RequestsDescription
add sitename queueidIt registers the message with a specific queue ID for a destination
send_site sitenameIt requests the delivery of all the queued mail for a specific destination
send_file queueidIt requests the delivery of a specific deferred message
refreshIt refreshes the log files and deletes the empty log files
purgeIt refreshes all the log files

Implementing flush Service Requests in Linux

In practice, administrators use higher-level Postfix commands to manage deferred mail and log files. Direct interaction with the flush service via these requests is typically handled internally or through the Postfix command set −

Viewing the Queue

To display the contents of the mail queue, use the postqueue command with the -p option −

postqueue -p 

A typical output looks like this −

flush Command in Linux1

The output displays the queue ID, message arrival time, and sender/recipient information.

Forcing Mail Delivery

To force Postfix to attempt delivery of all deferred mail, use the postqueue command with the -f option −

postqueue -f

Delivering a Deferred Message with a Specified Queue ID

To deliver a deferred message with a specific queue ID, use the -i option with the postqueue command −

postqueue -i 59H95397HE0Q

The -i option implements the traditional sendmail -qI command, by contacting the flush server.

Delivering a Deferred Message for a Specified Destination

To deliver all the deferred messages to a specific destination, use the -s option −

postqueue -s [192.168.28.190]

Understanding flush Service Configuration

Various configuration parameters can be used to modify the behavior of the flush service. Commonly used configuration parameters are listed below −

ParameterDescription
fast_flush_domainsIt is an optional parameter to specify the destination domains for the logfile
fast_flush_refresh_timeIt is used to specify the time after which the non-empty, unread log files are refreshed
fast_flush_purge_timeIt is used to specify the time after which the empty log files are deleted
flush Command in Linux2

These parameters are specified in the /etc/postfix/main.cf file.

Conclusion

The Postfix flush service in Linux is used to manage the deferred messages. Its equivalent commands are sendmail -qR or postqueue -f. It is specifically used to implement requests to deliver deferred messages by queue ID or destination. Moreover, it is also used to update the flush daemon log files.

In this tutorial, we explained the flush service, the requests it implements, its usage in Linux, and configuration parameters.