{"id":343,"date":"2010-12-21T17:44:01","date_gmt":"2010-12-21T17:44:01","guid":{"rendered":""},"modified":"2012-06-03T11:32:04","modified_gmt":"2012-06-03T11:32:04","slug":"usuwanie-poczty-kolejki-postfixa","status":"publish","type":"post","link":"https:\/\/drfugazi.eu.org\/en\/usuwanie-poczty-kolejki-postfixa\/","title":{"rendered":"Usuwanie poczty z kolejki Postfixa"},"content":{"rendered":"<p>Czasem trzeba wyrzuci\u0107 kilka maili z kolejki albo wykona\u0107 jak\u0105\u015b inn\u0105 operacj\u0119 wymagaj\u0105c\u0105 z\u0142o\u017cenia kilku polece\u0144 do kupy. Dla starych wyjadaczy to \u017caden problem i pewnie zrobiliby to bardziej optymalnie, ale ja w\u0142a\u015bnie postanowi\u0142em rozpocz\u0105\u0107 cykl, kt\u00f3ry pocz\u0105tkowo nazwa\u0142em &#8220;<b>Jednowierszowce<\/b>&#8220;, a teraz przemianowa\u0142em na &#8220;<b>Skrypty<\/b>&#8221; gdzie b\u0119d\u0119 wrzuca\u0142 jednowierszowe i nieco d\u0142u\u017csze skrypty shellowe (i inne), kt\u00f3re mam nadziej\u0119 b\u0119d\u0105 przydatne i zrozumia\u0142e dla szerszego grona u\u017cytkownik\u00f3w.<\/p>\n<p>Na pocz\u0105tek wyrzucimy z kolejki poczty kilka zwrotek, czyli maile od MAILER-DAEMON. Nie pytajcie mnie dlaczego &#8211; przyk\u0142adowo. Tym razem opisz\u0119 to krok po kroku. Oto przyk\u0142ad jak wygl\u0105da kawa\u0142ek kolejki w postfixie:<\/p>\n<pre><code># mailq\r\n-Queue ID- --Size-- ----Arrival Time---- -Sender\/Recipient-------\r\n571AAC45      48204 Tue Dec 21 07:52:39  MAILER-DAEMON\r\n                (connect to example.com[221.X.X.70]:25: Connection refused)\r\n                                         datadm@example.com\r\n...\r\n<\/code><\/pre>\n<p>No to wybierzmy sobie tylko te maile, kt\u00f3re s\u0105 od MAILER-DAEMON:<\/p>\n<pre><code># mailq|grep MAILER-DAEMON\r\n571AAC45      48204 Tue Dec 21 07:52:39  MAILER-DAEMON\r\n5C0671838      4528 Mon Dec 20 15:19:35  MAILER-DAEMON\r\n806BF1FB0     12469 Mon Dec 20 00:38:55  MAILER-DAEMON\r\n2CDC81BDE     47643 Mon Dec 20 12:05:33  MAILER-DAEMON\r\n623E21AFE      4096 Mon Dec 20 13:16:59  MAILER-DAEMON\r\n682491647     11799 Wed Dec 22 06:18:43  MAILER-DAEMON\r\n...\r\n<\/code><\/pre>\n<p>Wszelkie dzia\u0142ania na kolejce opieraj\u0105 si\u0119 na Queue-ID, potrzebujemy wi\u0119c tylko pierwsz\u0105 kolumn\u0119, mo\u017cemy to zrobi\u0107 np. tak:<\/p>\n<pre><code># mailq|grep MAILER-DAEMON|cut -d\" \" -f1\r\n571AAC45\r\n5C0671838\r\n806BF1FB0\r\n2CDC81BDE\r\n623E21AFE\r\n682491647\r\n...\r\n<\/code><\/pre>\n<p>I to wystarczy ju\u017c pos\u0142a\u0107 do polecenia <code>postsuper<\/code>:<\/p>\n<pre><code># mailq|grep MAILER-DAEMON|grep ^5|cut -d\" \" -f1|postsuper -d -\r\npostsuper: 571AAC45: removed\r\npostsuper: 5C0671838: removed\r\npostsuper: Deleted: 2 messages\r\n<\/code><\/pre>\n<p>Ograniczy\u0142em powy\u017cej zakres do tych, kt\u00f3re zaczynaj\u0105 si\u0119 od cyfry 5 (<code>grep ^5<\/code>), \u017ceby pokaza\u0107 Wam, \u017ce polecenia <code>grep<\/code> i <code>cut<\/code>, mo\u017cna zast\u0105pi\u0107 jednym poleceniem <code>gawk<\/code> (GNU awk):<\/p>\n<pre><code># mailq|gawk '\/MAILER-DAEMON\/ { print $1 }'|postsuper -d -\r\npostsuper: 806BF1FB0: removed\r\npostsuper: 2CDC81BDE: removed\r\npostsuper: 623E21AFE: removed\r\npostsuper: 682491647: removed\r\n...\r\n<\/code><\/pre>\n<p>Je\u015bli zdarzy si\u0119, \u017ce lista argument\u00f3w jest zbyt d\u0142uga, to przed <code>postsuper<\/code> nale\u017cy zastosowa\u0107 jeszcze polecenie <code>xargs<\/code>.<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Czasem trzeba wyrzuci\u0107 kilka maili z kolejki albo wykona\u0107 jak\u0105\u015b inn\u0105 operacj\u0119 wymagaj\u0105c\u0105 z\u0142o\u017cenia kilku polece\u0144 do kupy. Dla starych wyjadaczy to \u017caden problem i pewnie zrobiliby to bardziej optymalnie, ale ja w\u0142a\u015bnie postanowi\u0142em&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[],"tags":[],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7M9Tz-5x","jetpack-related-posts":[{"id":358,"url":"https:\/\/drfugazi.eu.org\/en\/how-remove-mail-postfix-queue\/","url_meta":{"origin":343,"position":0},"title":"How to remove mail from Postfix queue","author":"drfugazi","date":"Friday June 29th, 2012","format":false,"excerpt":"Sometimes you need to remove some mail from queue or do other things in shell. For experienced administrators this is not a problem, but I decided to write some usable shell commands and scripts for less experienced users. Here are few commands to remove mail from Postfix queue. Don't ask\u2026","rel":"","context":"In &quot;Oneliners&quot;","block_context":{"text":"Oneliners","link":"https:\/\/drfugazi.eu.org\/en\/category\/oneliners\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":384,"url":"https:\/\/drfugazi.eu.org\/en\/trusted-certificates-for-free-startssl\/","url_meta":{"origin":343,"position":1},"title":"Trusted certificates for free &#8211; StartSSL","author":"drfugazi","date":"Sunday August  3rd, 2014","format":false,"excerpt":"How many times did you see a pop-up message \"Security certificate of this site is not trusted!\"? We are used to it, and most of people even don't check who is Certificate Authority and for who is certificate issued. Just click and confirms that they know the risk. This is\u2026","rel":"","context":"In &quot;Security&quot;","block_context":{"text":"Security","link":"https:\/\/drfugazi.eu.org\/en\/category\/security\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/drfugazi.eu.org\/wp-content\/uploads\/2014\/08\/startssl.jpg?fit=1171%2C897&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/drfugazi.eu.org\/wp-content\/uploads\/2014\/08\/startssl.jpg?fit=1171%2C897&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/drfugazi.eu.org\/wp-content\/uploads\/2014\/08\/startssl.jpg?fit=1171%2C897&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/drfugazi.eu.org\/wp-content\/uploads\/2014\/08\/startssl.jpg?fit=1171%2C897&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/drfugazi.eu.org\/wp-content\/uploads\/2014\/08\/startssl.jpg?fit=1171%2C897&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":356,"url":"https:\/\/drfugazi.eu.org\/en\/postfix-2\/","url_meta":{"origin":343,"position":2},"title":"Postfix","author":"drfugazi","date":"Friday June 29th, 2012","format":false,"excerpt":"Postfix is Wietse Venema's mail server that started life at IBM research as an alternative to the widely-used Sendmail program. Postfix attempts to be fast, easy to administer, and secure. The outside has a definite Sendmail-ish flavor, but the inside is completely different. Built from source code, Postfix can run\u2026","rel":"","context":"In &quot;Mail system&quot;","block_context":{"text":"Mail system","link":"https:\/\/drfugazi.eu.org\/en\/category\/mail-system\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":348,"url":"https:\/\/drfugazi.eu.org\/en\/dovecot-2\/","url_meta":{"origin":343,"position":3},"title":"Dovecot","author":"drfugazi","date":"Monday June  4th, 2012","format":false,"excerpt":"Dovecot is an open source IMAP and POP3 email server for Linux\/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory.","rel":"","context":"In &quot;Mail system&quot;","block_context":{"text":"Mail system","link":"https:\/\/drfugazi.eu.org\/en\/category\/mail-system\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":272,"url":"https:\/\/drfugazi.eu.org\/en\/mail-delivery-configuration-ldap\/","url_meta":{"origin":343,"position":4},"title":"Mail delivery configuration with LDAP","author":"drfugazi","date":"Wednesday May 25th, 2011","format":false,"excerpt":"Sorry, this entry is only available in Polish. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.Ostatnim razem pisa\u0142em o uwierzytelnianiu u\u017cytkownik\u00f3w w katalogu LDAP aby umo\u017cliwia\u0107 im odbieranie i nadawanie poczty. Teraz nadszed\u0142\u2026","rel":"","context":"In &quot;LDAP&quot;","block_context":{"text":"LDAP","link":"https:\/\/drfugazi.eu.org\/en\/category\/ldap\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":351,"url":"https:\/\/drfugazi.eu.org\/en\/clamav-2\/","url_meta":{"origin":343,"position":5},"title":"ClamAV","author":"drfugazi","date":"Thursday June 14th, 2012","format":false,"excerpt":"Clam AntiVirus is an open source (GPL) anti-virus toolkit for UNIX, designed especially for e-mail scanning on mail gateways. It provides a number of utilities including a flexible and scalable multi-threaded daemon, a command line scanner and advanced tool for automatic database updates. The core of the package is an\u2026","rel":"","context":"In &quot;Mail system&quot;","block_context":{"text":"Mail system","link":"https:\/\/drfugazi.eu.org\/en\/category\/mail-system\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/posts\/343"}],"collection":[{"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/comments?post=343"}],"version-history":[{"count":0,"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/posts\/343\/revisions"}],"wp:attachment":[{"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/media?parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/categories?post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/drfugazi.eu.org\/en\/wp-json\/wp\/v2\/tags?post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}