1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

How do I write a cron to empty mail queue

Discussion in 'Plesk for Linux - 8.x and Older' started by d-woo, May 13, 2006.

  1. d-woo

    d-woo Guest

    0
     
    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!
     
  2. bob2

    bob2 Guest

    0
     
    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.
     
  3. d-woo

    d-woo Guest

    0
     
    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'
     
  4. bob2

    bob2 Guest

    0
     
    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.
     
  5. d-woo

    d-woo Guest

    0
     
    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?
     
  6. bob2

    bob2 Guest

    0
     
    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'
     
Loading...