Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like a bash script that sends me a weekly email displaying the breakdown of disk space used based on a array of file list. Would this be possible using the df -h

Had a look on Google to find anything that I could use without much luck.

share|improve this question
up vote 2 down vote accepted

Use cron to run a job and send the results to you.

Something like:

0 1 * * 6 /bin/df -h | mail -s "Disk usage" john.magnolia@example.com

in your crontab will run once a week on Saturday at 1AM.

This assumes that your server is set up to send mail to your email address.

If you need something more complicated, you can wrap the command in a script that does stuff.

share|improve this answer
    
Thanks this pointed me in the right direction of: cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html – John Magnolia Aug 23 '11 at 17:08

I don't understand the "array of file list part", but it's certainly possible with df and cron:

For a very basic version, add the following script to your /etc/cron.weekly directory:

#!/bin/bash
df -h | mailx youraddress@example.com -s "Weekly storage report" 

This requires that you have mailx and a working SMTP system installed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.