Linux - Having a daily report of servers by mail

April 2018

The monitoring and administration of Linux systems is a very difficult task when there is large number of interconnected servers, system resources and updates to each of them it,must continually monitored.

The following script creates a daily report intended to be sent by mail to the administrator.

Report content: Hard disk status and updates necessary (for Debian based system).
For other systems you must adapt to the existing systems management packages.

apt-get update
        echo To: receiver@domain.ext
        echo From:
 if [ "$( df -h | grep hda1 | cut -c40-42)" -ge "80" ]; then echo Subject: Reporting of `date +%e\ %B\ %Y` : LOW DISK SPACE
 else echo Subject: Daily reporting of `date +%e\ %B\ %Y` for `hostname`
        echo Reporting of `hostname`
        echo Disk used :
        df -h
        echo Server charge :
        echo Necessary updates
        apt-get -s upgrade
) | /var/qmail/bin/qmail-inject -fsenderr@domain.ext receiver@domain.ext

The above script will display a warning in the message if the hda1 disc has a filling rate greater than 80%. The messaging system used for sending in the example is qmail, but any other similar command (eg / usr / sbin / sendmail) can be used.

To make the script executable:

chmod +x /home/user/script/
  • Finally, creating an entry in the crontab will send daily by mail message (e.g. below 5:00 am):

crontab -e
  • Insert the following command line:

00 5 * * * /home/user/script/ > /dev/null 2>&1
Published by jak58. Latest update on November 25, 2009 at 07:03 AM by jak58.
This document, titled "Linux - Having a daily report of servers by mail," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Linux - Cutting a file into several parts
Installing an easy HTTP proxy-cache (polipo)