Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [tail]

Watching updates at the end of a file, with or without the tail utility

3
votes
0answers
17 views

Tailing file using less +F/shift-F, turn off line buffering?

When using tail -f, it prints each character as it is written to the file, but less +F won't print until it sees a linefeed. And if the data being written to the file does not contain linefeeds, must ...
2
votes
2answers
58 views

Why xargs can't work with tail -f?

I want tail -f /var/log/syslog | grep it with pattern "arpwatch" and send every line to myself via jabber: xmpp username@jabber.server using xargs tail -f /var/log/syslog | grep arpwatch | xargs ...
0
votes
2answers
36 views

alternative to `tail -f <filename>` allowing printing continuous stream from multiple files in multiple folders under the same parent folder [duplicate]

As far as I know, tail -f <filename> allows to continuously print newly appended data from one single file. What if I need to get content from multiple files located in multiple folders under ...
0
votes
1answer
22 views

daemon version of tail -f dir1/app.*.log.* dir2/app.*.log.*

I need to code a daemon that track the content of log-files on multiple hosts. The "log drives" (hosts are Windows Servers) are all mounted in a single Linux host. The tricky part is that the log-...
0
votes
0answers
96 views

tail: error writing 'standard output': Broken pipe

I tried to use some scripts which use tail commands on Debian stretch but I got tail: error writing 'standard output': Broken pipe. Does Debian handle tail and pipe syntax differently? Thank you in ...
0
votes
0answers
54 views

Tail with case statement is not working properly [duplicate]

I want to monitor the logs continuously and echo the output if keyword appears then continues the monitoring!! My question is how to perform the below operation tail the logs if keyword[down] ...
1
vote
0answers
66 views

tail -F is not working with while and case statement [closed]

I want to monitor the logs continously and echo the output if keyword appears then continues the monitoring!! My question is how to perform the below operation Tail the logs. If keyword[down] ...
-1
votes
0answers
65 views

How to multitail and grep for only one file?

I have set up a multitail with 4 windows (1 window to the left and 3 windows to the right). I would like to grep for the phrase "local" - but only for the first log file. I tried it like this but it ...
2
votes
1answer
308 views

Hex dump only the beginning and the end of a file with xxd [duplicate]

I am looking for a command to display three .png files using xxd, displaying the first two and last two lines of the hexadecimal for each. I have used the command below to display one file at a time ...
0
votes
3answers
71 views

How to make tail to automatically reconnect to a log file that was deleted and recreated together with its parent directory

I am using tail with option --follow=name to watch my log files in my servicemix instance (path = ${smx_home}/data/log/servicemix.log). ServiceMix have a 'nice' feature to restart clean with ...
24
votes
2answers
2k views

'tail -f' for a specific amount of time [duplicate]

I need to run tail -f against a log file, but only for specific amount of time, for example 20 seconds, and then exit. What would be an elegant way to achieve this?
3
votes
2answers
51 views

Concatenate multiple zipped files, skipping header lines in all but the first file

I have a collection of gzipped files that I want to combine into a single file. They each have identical format. I want to keep the header information from only the first file and skip it in the ...
4
votes
2answers
151 views

No log content with tail but when terminating a process I see content with less

Basically, I am running: nohup ./executable &> /tmp/out.log & In order to make sure the process is running I ran the command: tail -f /tmp/out.log But the only thing I can get from tail ...
1
vote
0answers
106 views

How to tail and grep log file, combine into a single line and pass as argument to another command

Using the following command, I managed to fetch error messages below (it's 3 lines). $ tail -f -n 0 error.log | grep -A2 --line-buffered "Internal server error" ! @79884flo2 - Internal server ...
1
vote
2answers
40 views

Stream contents of directory instead of reading all items [closed]

Is there a unix command I can use to stream the items/contents of a directory? Using Node.js, we can read everything into memory with: fs.readdir(dir, (err, items) => {}); but I am looking to ...
1
vote
2answers
204 views

Continuously print last line of file to single line on terminal

How can I continuously print the last line of a file to a single line in the terminal? The following works, but has a high performance hit. while true; do tail -1 /tmp/somelog | tr "\012" "\015"; ...
0
votes
1answer
58 views

Why `tail -f data_log | grep keyword` within tmux session could lead to hard disk exhaustion?

The scene is like, yesterday I need to check some api bug. So I logged into the log server. I opened up a tmux session, so I can reconnect to my work later. I typed in tail -f data_log | grep keyword ...
1
vote
2answers
174 views

How to continuously tail a log, find all files (sed), and display (cat) the found files

How to I continuously tail -f a log, find all files (sed), and display (cat) the found files example data in audit logs. tail -f /var/log/httpd/modsec_audit.log | sed 's/[^\/]*/\./;s/].*$//g' ...
7
votes
5answers
1k views

Display only the penultimate (second last) row of a text [duplicate]

I have a poem with an unknown number of rows and I want to display only the penultimate one. What command should I use?
10
votes
2answers
393 views

Read logs from one process during run of some command

It is difficult to properly formulate the title of this question, so I will describe more precisely my problem. I have some service which produces logs in the file logs.log. I have some other ...
0
votes
4answers
240 views

Quick head/tail command question

This is the output from the file I'm using: aaaaa bbbbb ccccc ddddd eeeee fffff ggggg hhhhh iiiii jjjjj I know using tail -n 5 filename will display this: fffff ggggg hhhhh iiiii jjjjj How do I ...
-1
votes
1answer
79 views

tail and bash: different output when same is expected

I'm trying to sort my logs and found that single digit dates were cut incorrectly. Now I want to either add a 0, or remove the extra space. Prior to that, I wanted to see how to get the correct lines ...
1
vote
0answers
133 views

How to tail -f until a text is found and no more lines are printed? [duplicate]

I'd like to integrate the following, similar, question: `tail -f` until text is seen The proposed solution consists in using the sed command which, when the test is found, exits. Tail will then fail ...
2
votes
1answer
75 views

How to restrict interrupt signal to just the child process?

I have a bunch of log files and I want to do a tail -f on them in a loop such that when I press Ctrl-C, the current tail -f gets killed and I proceed to the next log file: for log in *.log; do ...
13
votes
3answers
1k views

tail -f, insert line break after log is idle for 3 seconds?

When doing a tail -f error.log, how to insert programmatically a line break after nothing has been appened to the file for 3 seconds ? (obviously, once one line break has been added, no other line ...
1
vote
1answer
129 views

tail -f all files in a “living directory” [duplicate]

I am working with a directory where logs are constantly created. I use tail -f * in bash to view all the log entrys in the dir. However, when new files are created while the tail is running, the new ...
2
votes
2answers
468 views

How to get colored output with tail command [duplicate]

Below is the tail statement: tail -4 FDECMP1_$$.log I need to print the last 4 lines of file FDECMP1_$$.log in Red.
3
votes
1answer
107 views

How a tail a file that is given as the output of a find function? [closed]

I'm brand new in Unix environment. I would like to monitor the output of a calculation on a cluster with a function. I have tried this function I have put inside my .bashrc file under the alias ...
1
vote
3answers
294 views

Multiple Grep Searches

I wish to get the last line of a log file that matches a test string and output to another log file. I need to test for a number of different text strings and depending on the output send to a ...
0
votes
0answers
83 views

Tail+grep logs for 1 minute [duplicate]

Typical command to tail logs: tail -f *.log | grep error Now how could I make a process do this for a fixed time, e.g. to get a sample of error lines for one minute, then exit. Update: timeout is ...
7
votes
2answers
865 views

What logic does the command “exec tail -n +3 $0” from grub2 config have?

Creating custom menu entry, got stuck on this command: exec tail -n +3 $0 Tried it in terminal, got weird result, cannot understand, what this command exactly does and why grub needs it. Could you ...
3
votes
1answer
1k views

“tail -f | grep error” with while loop is not working

The below command is not giving any result. I want to grep the error line from the file and insert into table. Command which is not working: tail -f logfile.log | grep ERROR|while read msg; do psql ...
0
votes
1answer
488 views

tail not working on mac terminal

Due to my lack of experience with script language, (shame for a Mac user) I have referred to several sources: link seemed resolved with ls *.extension | xargs -n 1 tail -n +2 This didn't for me, ...
4
votes
1answer
491 views

make tail -f exit on a broken pipe

I want to watch a file until a bit of text appears I found this answer: `tail -f` until text is seen but when I tried it on ubuntu, it doesn't exit: $ echo one > test.txt $ echo two >> ...
0
votes
3answers
57 views

How to fillter and view only a substring of ip table Logs with tailf and sed?

one line of iptable log is: Jan 1 21:41:19 x kernel: [838760.885218] IPTables-Dropped: IN=eth0 OUT= MAC=x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:00:x:00:00:x:00:x:x:x:x SRC=x.x.x.x DST=x.x.x.x LEN=70 TOS=...
0
votes
0answers
66 views

How to use command on output of processed tail -f? [duplicate]

So I monitor some logs (/var/log/apache2/error.log) with the command tail -f, and only print the errors (grep ':error'). I combined both of these in a script (namely, watch_error_log.) NB: I am part ...
0
votes
0answers
27 views

tail/head piping remove newlines [duplicate]

If have the following file /tmp/f1.txt file coming from the stdout redirection of the result of a PostgreSQL bash script execution : id ----- 517 518 519 520 521 522 (6 rows) INSERT 0 6 I ...
3
votes
2answers
983 views

tail -f, but when the file is deleted and re-created (not appended)

I'm trying to watch for any new output of a log file. Another script (not under my control) is deleting the file then creating a new one with the same name. Using tail -f doesn't work because the file ...
3
votes
1answer
48 views

How to periodically watch a file from a list of files

I've a running java project that prints it's output to a file named in according to the current time: 03:45 ==> 03.out 13:24 ==> 13.out etc... Now I want to watch tail of the file currently ...
0
votes
1answer
102 views

Using mouse scroll with Multitail

Is there any way to use the mouse wheel, or the terminal window slide bar, to look through a multitail log? Ideally multitail would work almost exactly like tail (except with the obvious coloring).
2
votes
2answers
82 views

display only portions of lines from live log file

We have a log file that I often follow live with tail and use grep to filter for the lines I'm interested in. However, the lines contain a lot of data I'm not always interested in but they have been ...
14
votes
1answer
1k views

Why does piping to 'tail' change the contents of a line?

When I view the result of a SELECT with MySQL Workbench, it's correct with one single \ max@host 10:13:58: ~$ mysql -h db-master.domain.local -uuser -ppw db -e ' > SELECT > ...
1
vote
1answer
60 views

Is there a way to disable the delay of less +F?

Running less +F file is very convenient because you can switch in and out of forward-forever mode with Ctrl-C and ⇧-F respectively. Unfortunately new lines appear with a delay, which is very ...
-1
votes
2answers
121 views

How to tail multiple files without empty lines?

As I've noticed, a command such as tail -n +5 a b prints its output in a format like this: ==>a<== contents of a from line 5 to $EOF (including line 5) ==>b<== contents of b from line ...
0
votes
1answer
62 views

Tail-ing /sys/devices/platform/applesmc.768/light not working

Once upon a time, I cast this shellspell, # tail -f /sys/devices/platform/applesmc.768/light and it does produce, (0,0) Those file I read is light sensor abstraction file of Macbook Pro. ...
3
votes
1answer
136 views

Tail changing files

I'm trying to append file by watching data that constantly adding every second and pipe data to new files that will process it later. using tail -f 'data file' >> 'destination file' But some ...
0
votes
3answers
914 views

Is it possible to change tail's default line count?

When I use tail file, tail by default prints the last 10 lines. Is it possible to change that default in the system level?
1
vote
1answer
741 views

Can a 8GB USB drive run Linux? If yes, which type? [closed]

I have two USB drive and both are 8GB. But one is USB 3.0 with writing speed: 7.93mb/s and reading speed: 87.642mb/s, another is unknown (maybe 2.0) with writing speed: 6.764mb/s and reading speed: 16....
6
votes
2answers
1k views

Reading a named pipe: tail or cat?

I made a file descriptor using mkfifo fifo As soon as something is written to this pipe, I want to reuse it immediately. Should I use tail -f fifo or while true; do cat fifo; done ? They seem ...
0
votes
1answer
41 views

Too many emails sent when sending emails when specific URL has been visited in Apache Logs

In this question, a solution was found to automatically send an email each time a specific URL is visited (such as ?src=foo), as seen in the Apache logs: tail -F -n0 /var/log/apache2/...