Si /etc/cron.daily existe:
|
1 2 3 |
nano /etc/cron.daily/diskAlert chmod +x /etc/cron.daily/diskAlert |
Sinon avec crontab:
|
1 2 3 4 5 |
nano [chemin]/diskAlert chmod +x [chemin]/diskAlert crontab -e |
|
1 |
0 0 * * *[chemin]/diskAlert |
Contenu du fichier diskAlert
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#!/bin/sh df -H | grep -vE '^Filesystem|none|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usep -ge 80 ]; then echo "Le disque \"$partition\" est rempli à $usep% - $(date)" | mail -s "[Serveur ABC] Espace disque faible $usep%" contact@example.com fi done |