How to delete email QUEUE through command line or SSH

How you can delete email QUEUE through command line or SSH

If you are unable to delete your email queue from your WHM/Cpanel then you can use command line interface or SSh to delete your email queue, some time due to hacking or spamming that queue gonna be maximum and unabale to delete through Cpanel, so than through ssh you can delete that queue using this command.


/var/spool/mail/root is the place from were you can remove the mails,
if you want to remove mails of root, you can delete them from here /var/spool/mail/root
OR if you want to to remove the mails of a user then go /var/spool/mail/username

If you want to remove the mails from the exim then follow the following commands

  • exim -bp

Through this above command you will get some IDs like:

  • exim -bp 12d 3.0K 1Qe0j7-0004Fa-5x root@xxx.xxx.xxx.xx

After above command use below command to delete that specific message

  • exim -Mrm {message-id}

If you want to remove all the messages from exim queue, use below command, it will delete every thing in exim mail queue

  • # exim -bp | awk ‘/^ *[0-9]+[mhd]/{print “exim -Mrm ” $3}’ | bash

If you want to delete frozen messages, you may try below given commands

  • exiqgrep -z -i | xargs exim -Mrm

Alternate command to delete frozen mails

  • exim -bp | awk ‘$6 == “frozen” {print $3}’ | xargs exim -Mrm

You can check number of frozen email through below given command

  • exim -bp | grep frozen | wc -l
Both these below command also have the ability to delete the whole email queue
  • exim -bpru|awk {‘print $3’}|xargs exim -Mrm

If that command will not work, you may try

  • exim -bp | grep \< | awk ‘{print $3}’ | xargs exim -Mrm


Add a Comment

*