tail

How to pipe tail -f into awk

谁都会走 提交于 2019-12-01 03:33:32
问题 I'm trying to set up a script where an alert is generated when a certain string appears in a log file. The solution already in place greps the whole log file once a minute and counts how often the string appears, using the log line's timestamp to count only occurrences in the previous minute. I figured it would be much more efficient to do this with a tail, so I tried the following, as a test: FILENAME="/var/log/file.log" tail -f $FILENAME | awk -F , -v var="$HOSTNAME" ' BEGIN { failed_count

PHP built-in server error log location

大兔子大兔子 提交于 2019-12-01 02:36:05
I don't know if there's any? but is php built in web server also save its error logs in a file? for tailing purposes, like when creating virtual host in apache. UPDATE: i'm using mac osx thenickdude The built-in webserver doesn't log anywhere by default, so you need to provide a php.ini for it to customise this. For example, if you created a file called php.ini with this content: error_log = /Users/me/test.log log_errors = on date.timezone = UTC Then you can start PHP's built-in webserver like this: php -S 127.0.0.1:8080 -c php.ini And error_log() calls will be logged to the file you've

Get last line of shell output as a variable

穿精又带淫゛_ 提交于 2019-12-01 02:29:31
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. Fixed. - 2015-07-12 15.41.06.jpg 4512 files failed condition 177 image files updated The problem is that

Using tail -f on a log file with grep in bash script

孤人 提交于 2019-11-30 20:40:51
问题 I'd like to create a script that greps for a specific string in a log file that is being written to. I'd like to take the first result and put that into a variable for later use. This will be used though an SSH connection like so: ssh 'user@xxx.xxx.xxx.xxx' 'bash -s' < /usr/local/bin/checklog.sh string The command in a regular terminal tail -f /var/log/named.log | grep $1 > $var echo "${var}" When I try the above method, there's no output 回答1: Using a while loop may work for your situation,

dplyr and tail to change last value in a group_by in r

懵懂的女人 提交于 2019-11-30 19:07:32
while using dplyr i'm having trouble changing the last value my data frame. i want to group by user and tag and change the Time to 0 for the last value / row in the group. user_id tag Time 1 268096674 1 3 2 268096674 1 10 3 268096674 1 1 4 268096674 1 0 5 268096674 1 9999 6 268096674 2 0 7 268096674 2 9 8 268096674 2 500 9 268096674 3 0 10 268096674 3 1 ... Desired output: user_id tag Time 1 268096674 1 3 2 268096674 1 10 3 268096674 1 1 4 268096674 1 0 5 268096674 1 0 6 268096674 2 0 7 268096674 2 9 8 268096674 2 0 9 268096674 3 0 10 268096674 3 1 ... I've tried to do something like this,

Python to emulate remote tail -f?

£可爱£侵袭症+ 提交于 2019-11-30 19:02:45
We have several application servers, and a central monitoring server. We are currently running ssh with "tail -f" from the monitoring server to stream several text logfiles in realtime from the app servers. The issue, apart from the brittleness of the whole approach is that killing the ssh process can sometimes leave zombie tail processes behind. We've mucked around with using -t to create pseudo-terminals, but it still sometimes leaves the zombie processes around, and -t is apparently also causing issues elsewhere with the job scheduling product we're using. As a cheap-and-dirty solution

write to a file after piping output from tail -f through to grep

断了今生、忘了曾经 提交于 2019-11-30 17:00:42
问题 I'm looking to write to a file after piping output from tail -f through to grep. Say,write to a file "temp" for all lines with "Playing:" within in error_log "FreeSwitch.log". tail -f "/var/lof/freeswitch/freeswitch.log" | grep "Playing:" > temp but not working ! It is a centos 5.5 回答1: Maybe you have an issue with buffering? See BashFAQ: What is buffering? You could e.g. try: tail -f /var/lof/freeswitch/freeswitch.log | grep --line-buffered "Playing:" > temp 回答2: -f, --follow[={name

shell: delete the last line of a huge text log file [duplicate]

和自甴很熟 提交于 2019-11-30 13:03:18
问题 This question already has answers here : Remove the last line from a file in Bash (13 answers) Closed 2 years ago . I asked a question regarding popping the last line of a text file in PHP, and now, is it possible to re-write the logic in shell script? I tried this to obtain the last line: tail -n 1 my_log_file.log but I am not sure how can I remove the last line and save the file. P.S. given that I use Ubuntu server. 回答1: (Solution is based on sch's answer so credit should go to him/her)

Web implementation of “tail -f filename”?

▼魔方 西西 提交于 2019-11-30 09:34:28
I have a log file and want to create a webpage (possibly Python but not strictly) that will work much like unix "tail -f filename" command works (show new log lines when they are written to file). So that user will continuously see log right in browser. How would you implement this? Tailon is a python webapp that, among other things, provides tail -f like functionality. In addition, wtee (a sister project of tailon) can make all its stdin viewable in the browser - its use is identical to the unix tee command: tail -f filename | wtee Scullog , having capability of sharing the local drive to the

How do you continuously read a file in Java?

▼魔方 西西 提交于 2019-11-30 08:06:25
问题 I'm trying to figure out how to continuously read a file and once there is a new line added, output the line. I'm doing this using a sleep thread however it just seems to blow through the whole file and exit the program. Any suggestions what I'm doing wrong? Here is my code: import java.io.*; import java.lang.*; import java.util.*; class jtail { public static void main (String args[]) throws InterruptedException, IOException{ BufferedReader br = new BufferedReader( new FileReader("\\\