troubleshooting Question

script to get latest file and email

Avatar of santoshmotwani
santoshmotwaniFlag for Australia asked on
LinuxScripting Languages
25 Comments1 Solution448 ViewsLast Modified:
Hi Experts,

I have a production server ( windows 2008) , there are multiple processes running on that server. If a process fails due to some reason it creates a text file and stores it in a folder called email data.

What i am trying to do here is to write a script that will get the read that latest created txt file from that folder and email it to me.

I have mounted that folder on a ubuntu box.

I have a rough idea on how to get a latest file & read it .


get a latest file - find . -not -type d -printf "%T+ %p\n" | sort -n | tail -1

how to read a file :

FILE="/mnt/emaildata/1.txt"
OUT=$(awk '{ print $2 }' $FILE)
echo "*** error ***"
for ip in $OUT
do
   echo $ip
done


But i am unsure how do i structure the script so that it will only send the latest file created & i want it to run continuously or at least every 30 seconds.

Please help


Thanks
ASKER CERTIFIED SOLUTION
farzanj

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros