Feet in the Fire
Posted 07-15-2013 at 02:16 PM by mosiac
I didn't even realize that this site had a blog so I thought I'd get started and post something. I'm a Linux / Windows / VMware admin who got thrown into the mix instead of gently let down into it (something I'm sure many people are familiar with).
Anyway today's major issue was trying to figure out how to calculate space used by log files generated by a database over a specific date.
Well I knew that "df -h" would give me all the space used on a drive and "du -h /directory" would give me how much space that specific directory is but how do I add in the date of the files I need.
I had to come to this forum and ask for help because all I really had going on was
Which if we break it down does a find for file types in a directory with the name *log and then a creation time of 610 minutes ago, which at the time I wrote it was midnight, it pumps that out to my term which I think run du on and pump that out to an awk statement to give me the total space used.
This was fine but I really didn't like the ctime part it wasn't specific enough and would need to be changed to recalculate for what time I was running it so I posted the question and I got this from user druuna (THANKS AGAIN!)
That gave me my timeframe to the specifics I was looking for and it worked out great. The next step will be pruning 30 gigs of log files generated in less than 24 hours...
Anyway today's major issue was trying to figure out how to calculate space used by log files generated by a database over a specific date.
Well I knew that "df -h" would give me all the space used on a drive and "du -h /directory" would give me how much space that specific directory is but how do I add in the date of the files I need.
I had to come to this forum and ask for help because all I really had going on was
Code:
find /directory -type f -name "*.log*" -cmin -610 2> /dev/null | xargs du -b -h 2>/dev/null | awk '{total += $1; print $0} END{print total}'
This was fine but I really didn't like the ctime part it wasn't specific enough and would need to be changed to recalculate for what time I was running it so I posted the question and I got this from user druuna (THANKS AGAIN!)
Code:
touch --date="2013-07-15 00:00:00" /tmp/token1 touch --date="2013-07-15 23:59:59" /tmp/token2 find /dirX -type f -newer /tmp/token1 -not -newer /tmp/token2 -exec stat -c%s {} \; | awk '{total += $1;print}END{print total}'
Total Comments 0