The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Exim queue size - auto-mail to myself

Discussion in 'E-mail Discussions' started by ebizindia, Dec 16, 2011.

  1. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    Hi

    I want to setup a cronjob to auto mail the Exim queue size to myself so that I can take suitable action if the queue becomes too large.

    The following command works on the shell prompt but does not work from a shall script.

    exim -bpc | mail -s'Exim queue size' email@domain.com

    When run from a shell script, it just sends a blank mail. The queue size is not being piped.

    Also, I want to modify this to alert me only when the size goes above, say 5000 or some other number. How to do that?

    Thanks in advance!
     
  2. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    Any tips for making sure how to pipe the output of exim command from the shell script?
     
  3. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    I created a file named Exim_queue_size and in that I have one line:
    Code:
    exim -bpc | mail -s'Exim queue size' email@domain.com
    
    (replaced the email address of course).

    I made that file executable:
    Code:
    chmod +x Exim_queue_size
    
    and executed it:
    Code:
    ./Exim_queue_size
    
    and I got the Exim queue size to my email.
     
  4. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    I did just that and I am getting a blank email. The mail even responds with "Null message body, hope that's OK" :(

    funny thing is - this command works on the shell prompt, but not from the script file.

    Any clues to what could be wrong in my case?

    I even tried this:
    exim -bpc > stats | cat stats | mail -s'Exim queue size' email@domain.com

    Looks like mail is not taking the input from the piped data.
     
  5. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    Sorted. I had not entered a CR at the end of the line in the script file. :(
     
  6. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    Sorry I posted too fast. While the shell script works when executed from the shell prompt, it send blank data (though subject etc are fine) when executed with cron.
     
  7. faisikhan

    faisikhan Well-Known Member

    Joined:
    Dec 12, 2011
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Islamabad, Pakistan
    cPanel Access Level:
    Root Administrator
    Hi,

    Are you sure the location path for the exim script file is correctly entered into the cron jobs and try giving the full path to exim because it may probably be the path issue as well. For example the script can be like this:

    #!/bin/sh
    /usr/sbin/exim -bpc | mail -s'Exim queue size' email@domain.com

    and the cron entry will be like(Note: it will be executed after every two seconds):
    */2 * * * * sh /root/Exim_queue_size.sh

    Also when you run the script, see the exim and server logs to get more help and clues, but try above and if still problem exists, get back to me :)
     
  8. ebizindia

    ebizindia Well-Known Member

    Joined:
    Oct 13, 2005
    Messages:
    72
    Likes Received:
    2
    Trophy Points:
    8
    Location:
    Kolkata, India
    cPanel Access Level:
    Root Administrator
    Thanks Faisikhan. I believe the cronjob run of the file was not able to locate the exim path. After adding the full path, it does send the current queue size.
     
Loading...

Share This Page