Skip to content
Advertisement

Tag: tail

Filter followed tail to file using grep and redirect

I want to get the output of tail -f /var/log/apache2/error.log | grep “trace1” into a file. But tail -f /var/log/apache2/error.log | grep “trace1” > output.txt does not work, while the first command gives an output in my terminal window as expected. I guess it has to do with the follow-parameter, because if I omit the “-f”, the output file is

Read last line of file after the file was modified

I have a problem with reading the last line of file in Linux Ubuntu. I have a file named auth.log and I’m trying to read it last line after new line was added (after file was modified). I know i need to use tail -1 /var/log/auth.log to get last line but I don’t know how to check the file every

Starting container process caused “exec: \”tail -f /dev/null\”: stat tail -f /dev/null: no such file or directory

Because I am trying to keep a container running I specified the “tail -f /dev/null” as command in the docker compose file: After I run docker-compose up I get the following error: ERROR: for serviceName Cannot start service serviceName: b’OCI runtime create failed: container_linux.go:348: starting container process caused “exec: “tail -f /dev/null”: stat tail -f /dev/null: no such file or

truncate shell command output from last line matching a string until EOF

I would like to truncate the output of a shell script and only print the part between the last line matching a string/regex and EOF. E.g when running letsencrypt certbot renew –post-hook “service apache2 reload; service nginx reload” I get something like Now what I want to have is everything after the last ——- line, so the desired result would

Get last 30 minutes from log file

I have a log file that contain logs as follows 1486307866.155 is the time in unix format with corresponds to 2017-02-05 07:17:46 (Format : Y-m-d H:i:s) I need a unix command that give me the logs within last 30 minutes in the following format and discarding any details that i don’t need. 2017-02-05 07:17:46|68.146.231.80|clients1.google.com:443 Answer Using GNU date and GNU

Tailing a file from where I left off before?

Suppose I have a file. I tail its last 10 lines and got some data. And the next time I come to tail, its length increases by 4. So I need to tail only that many lines to get data. Is there a simple command line for this? Like a mix of tail, wc, and grep? Answer If you save

Advertisement