I need help in creating a script that will run once a day in afternoon and collect the information of each partition(Disk Space , Total and Used) and send it to my email.
Please help im very very new in this scripting thing.
I need help in creating a script that will run once a day in afternoon and collect the information of each partition(Disk Space , Total and Used) and send it to my email.
Please help im very very new in this scripting thing.
Provided you have an MTA configured on that machine to accept and relay mail for you (on a server that should be the case) try this:
$ df -h | mail -s "Filesystem usage report for `hostname`" [email protected]
(MTA = Postfix, Exim, etc.)
If that fits your needs, add it to your crontab to run every day:
$ crontab -e
An editor will open. Add a line like this:
@daily df -h | mail -s ...
Save and close.
This will make it run with the other daily tasks. If you need a report on a specific time of the day or error logging to a specific address, please read about the cron syntax (a lot of this is on the Internet - here's one random website). For example:
[email protected]
# at 5 a.m every day:
0 5 * * * mycommand
In case you can't send out mail on that machine directly, read this or the answer by @hakermania on how to do that (many more ways exist).