Search

Tuesday 20 April 2010

Determining free disk space in Linux

Just use the df command:

df /

or

df -P

will generate a usage table.

To just extract the 'used' portion:

df=($(LC_ALL=C df -P /)); echo "${df[11]}"

Email the report from a shell script:

df -h | mail -s “disk space report” fromage@cheese.com

If you don't have mail installed, you can use sendmail, which would be:

df-h | sendmail fromage@cheese.com

OR if you want to get the results of this (or any other linux command) in a pop up x window then first redirect the output of a command to a file:

df -h > otterlog.txt

Then open this file in a pop up:

xmessage -file otterlog.txt

No comments:

Post a Comment