Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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? –  SvW Oct 4 '11 at 16:40
1  
so.... you have a solution. It works. It fits on one line. What's the question? –  voretaq7 Oct 4 '11 at 17:16
add comment

2 Answers

up vote 9 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
add comment

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
2  
@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 me@example.com -s "runforever didn't" –  DerfK Oct 4 '11 at 17:52
1  
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
add comment

Your Answer

 
discard

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.