Linux HowTo - Automatically Find the Most Recent File in a Directory and Email it Out
Submitted by gpmilliken on Wed, 11/24/2010 - 06:21
On one of our systems we setup mpstat to generate load numbers to a file and email them out every 6 hours.
Some folks want the report every ten minutes, so they can keep a close eye on the system.
So we setup a cron job to run every ten minutes. it needs to find the most recent mpstats log file and email that out.
Here's the code in Linux korn (or bash):
cat `ls -rt $BACKUP_LOG_DIR/*mnpstat*log | tail -1` | mailx -s "XYZ Flash mpstat report" me@foo.bar,you@foo.bar
George
»
- gpmilliken's blog
- Login to post comments
