Script df

Basically I want to write a script which will run this [cmd=]df -k[/cmd]

I want it to do it automatically at a certain time and email the output. Can anyone help please?
 
crontab(5)

Don't even need a script.

Code:
*/10 * * * *    /bin/df -k | /usr/bin/mail -s "df output" some.email.address 2>&1
 
parsing a table

Ok. I have changed my structure. I now have my output, however I want to parse it using perl or sed etc. I want to check each % and if it reaches a certain threshold to alert me.

Any idea how?
 
Lilly_S said:
any idea how?
Yes, using perl or sed. Perl is probably easier if you also want to do something based on the info.
 
Ok, I will have a look at perl as I am new at this. If anyone has any idea how to do it please let me know.
 
Here's a start :)
Code:
df | perl -ne 'next if /^(Filesystem|devfs|procfs|linproc)/;if (/(\d+\%)\s+\S+/){$p=$1;} if( $p > 90){print;}'
 
Back
Top