Count Postfix queue entries by queue name
Build a paste-ready command, then review its compatibility and effects before running it.
postqueue -j | jq -r '.queue_name' | sort | uniq -c | sort -nrread-onlyno known side effects Compatibility
LinuxVerified for Linux using posix, bash, zsh syntax.
Operational knowledgereview due 2027-01-20
Requirementspostqueuepostqueue must be installed and available on PATH.
Version supportpostqueue Current supported releasesVerified for linux using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals42 deferredRepresentative successful output; values vary with the selected target and system state.
Known errorspostqueue: command not foundpostqueue is missing or is not available on PATH.
Verifypostqueue -j | jq -r '.queue_name' | sort | uniq -c | sort -nrThe output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01postqueueCommandRuns the postqueue stage of this one-liner.
02-jOptionConfigures postqueue with the -j option.
03|PipelinePasses the output on the left to the command on the right.
04jqCommandRuns the jq stage of this one-liner.
05-rOptionEnables raw, recursive, or reverse mode for this command.
06'.queue_name'ArgumentPasses '.queue_name' to jq.
07|PipelinePasses the output on the left to the command on the right.
08sortCommandRuns the sort stage of this one-liner.
09|PipelinePasses the output on the left to the command on the right.
10uniqCommandRuns the uniq stage of this one-liner.
11-cOptionConfigures uniq with the -c option.
12|PipelinePasses the output on the left to the command on the right.
13sortCommandRuns the sort stage of this one-liner.
14-nrOptionConfigures sort with the -nr option.
Example input
postqueue -j | jq -r '.queue_name' | sort | uniq -c | sort -nr
Example output
42 deferred
3 active
1 hold
Illustrative output — exact values vary by system and data.
Official sources