Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

trying to spit out last 100 lines of catalina.out and email them to myself. Can someone suggest a quick oneliner on how to do this?

I can only come up with something like:

tail -100 catalina.out | /bin/mail -s blah myemailaddress
share|improve this question
What's wrong with your version? – Sven Oct 4 '11 at 16:40
so.... you have a solution. It works. It fits on one line. What's the question? – voretaq7 Oct 4 '11 at 17:16
up vote 10 down vote accepted

I would recommend using

tail -100 catalina.out | /bin/mail -s blah myemailaddress

I think you should find the results handy.

share|improve this answer
add the 2>&1 bit to get the errors as well :) – CMag Nov 3 '11 at 15:34

What you've got will work just fine.

share|improve this answer
thanks, you're right, i was missing something – CMag Oct 4 '11 at 17:47
do you think its appropriate to add this method to commands that take a long time, and you want to be notified when they complete? – CMag Oct 4 '11 at 17:48
@Clustermagnet I do that all the time. I even do that to commands that should never complete, so I'm notified if they do. If it makes a lot of noise then I might not pipe the output to the email though. Something like runforever >/dev/null | mail -s "runforever didn't" – DerfK Oct 4 '11 at 17:52
You could do, alternatively you could wrap the command in a script, redirect the command's output to a file, wait for it to finish, test it's return status and send an email based on that. – Iain Oct 4 '11 at 17:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.