help me write a shell script

Discussion in 'Site & Server Administration' started by nevetS, Mar 31, 2005.

  1. #1
    I want to do the following:

    Run a program (qmHandle) that shows me what my mail queue looks like.

    I want to send the resulting text to myself via e-mail, and run this all via a cron job several times a day.

    I'm running qmail - but I should be able to translate any sendmail commands easily.

    I just found 2000 spams going out through my server and stopped it, found a vulnerability, and capped it off, but then again you never know. I'd like to monitor the queue pretty regularly over the next week to see if anything else is going out.
     
    nevetS, Mar 31, 2005 IP
  2. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nullbit, Mar 31, 2005 IP
  3. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you want a quick fix, all you need is probably something like:

    
    qmHandle | mail -s "Mail queue report" your@email.com
    
    Code (markup):
    Presuming qmHandle prints to StdOut in non-interactive mode

    Add the above to your crontab. I posted the basics on using cron a while back.
     
    nullbit, Mar 31, 2005 IP
    nevetS likes this.
  4. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #4
    excellent. Much easier than I thought:

    In my crontab:
    
    05 * * * * cd /path/to/qmhandle; ./qmHandle -R |/var/qmail/bin/qmail-inject myemail@dress
    Code (markup):
    I didn't have "mail" available, so I man'ned qmail inject and it was just as easy for syntax. I thought it would have been much harder...
     
    nevetS, Mar 31, 2005 IP