Koozali.org: home of the SME Server

Need crontab script to send email notices to admin

BobWilliams

Need crontab script to send email notices to admin
« on: November 09, 2004, 05:28:02 PM »
I need to create a script to have Crontab execute a job that emails the output of say "df -h" to the admin account field 'forwarding address for administrative messages' but I don't know the script commands. Can anyone help me?

Bob...

Offline Kobus

  • *****
  • 153
  • +0/-0
    • http://www.fullnet.co.uk
Need crontab script to send email notices to admin
« Reply #1 on: November 11, 2004, 11:44:37 PM »
you could always write the output of df to a file and then use mail to send it to an email address.

shove it into cron and you should get regula emails
Kobus............

BobWilliams

Need crontab script to send email notices to admin
« Reply #2 on: November 11, 2004, 11:55:55 PM »
Thanks for the reply kbensch. I did just that.
'date' > /df-test
mail -s "subject" mail-address < /df-test
and used the new SME Server Manager - Crontab Manager panel to launch the script. Works great.

Bob...

monkey

Need crontab script to send email notices to admin
« Reply #3 on: November 13, 2004, 05:34:26 AM »
I have a script for emailing ping logs to my email address for work. Its a bit crude, but works.

Code: [Select]

FROMMAIL="XXXXXXXXX@XXXXXX.com"
TOMAIL="XXXXXXXXXX@XXXXXX.com"
MAILFILE=/tmp/basename ${0}.$$

PINGLOG="/export/home/szr52z/log/vpn_log.txt"

SentPage() {

        DATE=date "+%H:%m %Y-%m-%d"

        echo "From: ${FROMMAIL}"                                > ${MAILFILE}
        echo "To: ${TOMAIL}"                                    >> ${MAILFILE}
        echo "Subject: [VPN Ping Report]."          >> ${MAILFILE}
        echo "Content-Type: text/plain; charset=us-ascii"       >> ${MAILFILE}
        echo "Content-Transfer-Encoding: 7bit\n\n"              >> ${MAILFILE}

        echo " "                                                >> ${MAILFILE}
        echo "Time stamp: ${DATE}."                             >> ${MAILFILE}
        echo " "                                                >> ${MAILFILE}

        echo "The failed ping attempts are as follows:"         >> ${MAILFILE}
        echo " "                                                >> ${MAILFILE}
        echo "-----------"                                      >> ${MAILFILE}

/usr/bin/cat ${PINGLOG} >> ${MAILFILE}

        /usr/lib/sendmail -oi -t -oem < ${MAILFILE}
}

main() {

        if [ "${PINGLOG}" != "" ] ; then
                SentPage
        fi
}

main


Tho SME doesn't have send mail, it might help give an idea atleast.

BobWilliams

Need crontab script to send email notices to admin
« Reply #4 on: November 13, 2004, 02:34:47 PM »
Thanks for the input monkey. That script will be a great help to me learning scripting on SME. I think this product is great and the support the members provide is outstanding.

Thanks

Bob...