LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 06-10-2006, 06:34 AM   #16
linuxdawg
Member
 
Registered: Aug 2004
Distribution: Suse
Posts: 44

Rep: Reputation: 16
Emailing output of tail -f


How would I be able to do something like this:

tail -f log | grep "I'm finished" | mail -s "It Is Finished" me@mine.com

What I want is as soon as tail -f detects the string "I'm finished", to email me@mine.com the output of the "grepped" string (not the entire log) and return me to a command-prompt.

Is that doable?
 
Old 06-12-2006, 01:28 AM   #17
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
check out this thread
http://www.linuxquestions.org/questi...d.php?t=438231
 
Old 06-12-2006, 04:46 AM   #18
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
You could use process substitution:
Code:
#! /bin/bash

while read
do
	mail -s "New line in logfile" dude <<- EOF
	Hi Dude,
	a new line was appended to your logfile. Here it is:
	$REPLY
	EOF
done < <( tail -f logfile )
Note that this will spawn an extra process for the tail command, which will still be running if the script itself is finished.
 
Old 10-14-2006, 04:07 PM   #19
oily_rags
Member
 
Registered: Sep 2004
Posts: 128

Rep: Reputation: 15
hi i'm trying to do a tail of the processes under my system. I can't seem to get it to work. I have tried doing tail this way

tail -f|ps aux

The processes display but it is static it's not updating the processes. I'm doing this just to understand the tail and Pipe commands, I might want to try redirecting the output to a text file too just for fun. Any thoughts guys? Thanks
 
Old 10-16-2006, 02:19 AM   #20
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Quote:
i'm trying to do a tail of the processes under my system.
What do you mean by this? Do you want to run tail on the output of some of your processes? Or do you want
tail to filter the output of your "ps" command, that gives you a list of processes?

Assuming you mean the latter:
ps -aux just lists some running processes once, not continuously, so you don't need tail's -f option.
Also, I think you have the order of the commands reversed:
Code:
ps -aux | tail
displays only the last few lines of ps's output. You can control how many lines you want by adding "-n" (replace n with the number you want) to "tail".

And finally, try to start a new thread when you have a question, rather than hijacking someone else's, which is against the forum policy.

Last edited by timmeke; 10-16-2006 at 02:20 AM.
 
  


Reply

Tags
bash, script, source


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables - why am I still being redirected? michaelsanford Linux - Networking 1 05-23-2005 03:52 PM
GPG and redirected input Vookimedlo Linux - Software 1 04-30-2005 04:32 PM
Is a Domain being redirected? rigel_kent Programming 0 02-14-2005 06:43 AM
my domain is getting redirected to a different ip. QS_Shorty Linux - Newbie 3 02-10-2004 08:22 PM
Some windows redirected to console (not in VNC) jswilson Red Hat 6 10-31-2003 03:22 PM


All times are GMT -5. The time now is 11:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration