tail

how to continue run script after tail -f command

天涯浪子 提交于 2020-04-07 03:22:57
问题 I have the following script: tail -f nohup.out echo 5 When I press Ctrl + C on tail -f , the script stops running: the 5 is not printed. How can I run the command echo 5 after I stop the tail command? 回答1: Ctrl + C sends the SIGINT signal to all the processes in the foreground process group. While tail is running, the process group consists of the tail process and the shell running the script. Use the trap builtin to override the default behavior of the signal. trap " " INT tail -f nohup.out

how to continue run script after tail -f command

若如初见. 提交于 2020-04-07 03:20:40
问题 I have the following script: tail -f nohup.out echo 5 When I press Ctrl + C on tail -f , the script stops running: the 5 is not printed. How can I run the command echo 5 after I stop the tail command? 回答1: Ctrl + C sends the SIGINT signal to all the processes in the foreground process group. While tail is running, the process group consists of the tail process and the shell running the script. Use the trap builtin to override the default behavior of the signal. trap " " INT tail -f nohup.out

Get last line of shell output as a variable

℡╲_俬逩灬. 提交于 2020-01-29 05:58:10
问题 I am working on a shell script with exiftool to automatically change some exif tags on pictures contained in a certain folder and I would like to use the output to get a notification on my NAS (a QNAP) when the job is completed. Everything works already, but - as the notification system truncates the message - I would like to receive just the information I need, i.e. the last line of the shell output, which is for example the following: Warning: [minor] Entries in IFD0 were out of sequence.

Get last line of shell output as a variable

我是研究僧i 提交于 2020-01-29 05:55:44
问题 I am working on a shell script with exiftool to automatically change some exif tags on pictures contained in a certain folder and I would like to use the output to get a notification on my NAS (a QNAP) when the job is completed. Everything works already, but - as the notification system truncates the message - I would like to receive just the information I need, i.e. the last line of the shell output, which is for example the following: Warning: [minor] Entries in IFD0 were out of sequence.

Shell Script to get exception from logs for last one hour

独自空忆成欢 提交于 2020-01-23 07:38:21
问题 I am developing script which will grep logs of last one hour and check any exception and send email for solaris platform. I did following steps grep -n -h date +'%Y-%m-%d %H:%M' test.logs above command gives me line number and then i do following tail +6183313 test.log | grep 'exception' sample logs 2014-02-17 10:15:02,625 | WARN | m://mEndpoint | oSccMod | 262 - com.sm.sp-client - 0.0.0.R2D03-SNAPSHOT | 1201 or 101 is returned as exception code from SP, but it is ignored 2014-02-17 10:15:02

Traversing TEI in Python 3, text comes up empty for some entities

青春壹個敷衍的年華 提交于 2020-01-16 04:59:08
问题 I have a TEI-encoded xml file with entities as follows: <sp> <speaker rend="italic">Sampson.</speaker> <ab> <lb n="5"/> <hi rend="italic">Gregory:</hi> <seg type="homograph">A</seg> my word wee'l not carry coales.<lb n="6"/> </ab> </sp> <sp> <speaker rend="italic">Greg.</speaker> <ab>No, for then we should be Colliars. <lb n="7" rend="rj"/> </ab> </sp> The full file is very large but can be accessed here: http://ota.ox.ac.uk/desc/5721. I'm attempting to use Python 3 to traverse the xml and

Piping tail output though grep twice

孤街浪徒 提交于 2020-01-08 17:14:10
问题 Going with a typical Apache access log, you can run: tail -f access_log | grep "127.0.0.1" Which will only show you the logs (as they are created) for the specified IP address. But why does this fail when you pipe it though grep a second time, to further limit the results? For example, a simple exclude for ".css": tail -f access_log | grep "127.0.0.1" | grep -v ".css" won't show any output. 回答1: I believe the problem here is that the first grep is buffering the output which means the second

tail command showing log file contents in non-real time

丶灬走出姿态 提交于 2020-01-06 08:39:51
问题 I have a C++ application (on Solaris 10) that shows log output based on the time chronological transactions. For example, before establishing a connection to Database server, it prints in stdout as: "Connecting to DB" and after the call to connect, if successful, says "Connected to DB", if failed, says, "failed to connect to DB" and so on. Now, when the application is run, the output (stdout) gets redirected to a log file as below: appl > app.log And, on another session, to see what's going

Why can't I filter tail's output multiple times through pipes?

只愿长相守 提交于 2020-01-06 02:25:48
问题 Unexpectedly, this fails ( no output ; tried in sh , zsh , bash ): echo "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played | sed 's#pl#st#g' Note that two times grep also fails, indicating that it's quite irrelevant which commands are used: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played | grep played grep alone works: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f /tmp/t | grep played played sed alone works: # echo -e "foo\nplayed\nbar" > /tmp/t && tail -f

How to get “instant" output of “tail -f” as input?

回眸只為那壹抹淺笑 提交于 2020-01-02 07:13:42
问题 I want to monitor a log file, when a new log message match my defined pattern (say contain “error”), then send out an email to me. To do that, I wrote a python script monitor.py, the main part looks like: import sys for line in sys.stdin: if "error" in line: print line It works well when I use tail my.log | python monitor.py , then I switch to tail -f my.log | python monitor.py , then it doesn’t work, at least not immediately. I have done some tests, when the new content to the log accumulate