• The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

How do I write a cron to empty mail queue

D

d-woo

Guest
I have placed a file in /etc/cron.hourly entitled cron-clearmailqueue

The code is as follows:

Code:
#!/bin/sh
#
cd /var/qmhandle
./qmHandle -D #deletes all

but the queue is not emptying every hour on the 45 minute mark, which is when my hourlys are set to go.

I invoke the line commands manually:
cd /var/qmhandle
./qmHandle -D


and it clears the queue just fine.

What am I missing here?

Thanks!
 
Have you tried to run your shell script manually to see if any errors are returned? You will need to type in the full path to the qmHandle script. It also looks like you may need to remove the "#deletes all" line after the qmHandle switch.

Here is what mine looks like that removes the messages with the subject failure notice every hour on the 15 minute mark.

/home/qmHandle -l
/home/qmHandle -S'failure notice'

I have it set to list the message queue first and then delete the messages. This way when the cronjob e-mails me the results I can see what is in the mail queue and what was deleted.
 
Hi bob2,

Yes, I've run both lines manually with no issues. In fact I'm having to do this two to three times each day...which is why I want to setup the cron.

Do you not have the line
Code:
#!/bin/sh
at the top of your cron file?

So...the total contents of your /etc/cron.hourly file is as follows?

Code:
/home/qmHandle -l
/home/qmHandle -S'failure notice'
 
Yes I do have the #!/bin/sh at the top of the shell script. How do you run the script manually. You should be able to run the script manually as follows: ./scriptname Not by manually typing each line at the command prompt. Does it output any errors after running the script manually. Also have you made sure the file is chmodded with the correct permissions.
 
Ahhh...I see what you meant ...running the cron file manually.

The manual command does not work when executed from /etc/cron.hourly, but the cron is working fine now. I'm having it to execute a php file in my /home/vhosts/domain/cronjobs folder

Thanks for your help!

Additionally:
The files that I am wanting to remove are the ones with 'failure notice' in the subject.

I tried using the -S command, as you did in SSH in /var/qmhandle/:
Code:
./qmHandle -S'failure notice'

but I received the following message:

Code:
qmHandle v1.0.0
by Michele Beltrame

Wrong parameters entered, available ones are:
  -l   : list message queues
  -L   : list local message queue
  -R   : list remote message queue
  -s   : show some statistics
  -vN  : display message number N
  -dN  : delete message number N
  -D   : delete all messages in the queue (local & remote)
Additional (optional) parameters are:
  -c   : display colored output
  -N   : list message numbers only
         (to be used either with -l, -L or -R)

You can view/delete multiple message eg -d123 -v456 -d567

I'm such a newbie when it comes to Plesk boxes. Looks like I have qmHandle v1.0.0

What version do you have?
 
I am running version 1.2.0. It looks like you need to update your qmHandle since it does not have the -S switch. If it makes any difference here is what my script looks like

#!/bin/sh
/home/qmHandle -l
/home/qmHandle -S'failure notice'


You should be able to input the path to your qmHandle script since I think you said yours was in /var and mine is in /home

Here is what yours should look like when you get your qmHandle updated.

#!/bin/sh
/var/qmHandle -l
/var/qmHandle -S'failure notice'
 
Back
Top