Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1646  / 2 Years ago, thu, february 10, 2022, 5:06:09

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.


More From » scripts

 Answers
0

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.)



Example emailed report



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).


[#35529] Saturday, February 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
avilyexplor

Total Points: 20
Total Questions: 102
Total Answers: 120

Location: Maldives
Member since Mon, Jun 21, 2021
3 Years ago
;