Sponsored Content
Top Forums Shell Programming and Scripting How to perform action on newest line in log using tail? Post 302397407 by frans on Monday 22nd of February 2010 04:23:58 AM
Old 02-22-2010
Wrench

The problem is that more than 1 line could have been added while your script slept Smilie
The best is to perform (Pseudo-code) :
line count (wc -l), calc the difference with previous count, tail the difference from your file, set your previous-count-variable to the new count, sleep, loop.
Code:
OLD=0
while true
do
    COUNT=$(wc -l < $FILE)
    DIFF=$((COUNT-OLD))
    if [ $DIFF -gt 0 ]
    then
        tail -n $DIFF $FILE
        OLD=$COUNT
    elif [ $DIFF -lt 0 ] # Can happen (logrotate...)
        OLD=0
        continue
    fi
    sleep 1
done

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perform action file name written to the pipe

Hello, I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe. There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file. cat test.sh... (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies

2. Shell Programming and Scripting

perform a check based on number of @ in a log line

Hello, I am intending to perform a check based on number of "@" , present in a line in a log file . The idea is basically to perform a check on cc or bcc sender, based on an email log, which shows all the for email address. Say if the number of @ is more than 30, I will consider it as a mass... (12 Replies)
Discussion started by: fed.linuxgossip
12 Replies

3. Shell Programming and Scripting

Need help in searching 2 files for strings then perform an action

I have 2 files. I basically want to search both of them to see if the 1st column ($1) matches and if it matches then check to see if the 2nd column ($2) matches, then execute some code showing the results of the matches. File 1: AAA 123 misc blah BBB 456 CCC 789 File 2: ... (2 Replies)
Discussion started by: streetfighter2
2 Replies

4. Shell Programming and Scripting

create dir in main &subdirs,perform action

Hi, I have one dir which has N subdirs.For ex: /home/user/Project_Src /home/user/Project_Src/Dir_A /home/user/Project_Src/Dir_A/subdir/sub_dir2 /home/user/Project_Src/Dir_A/subdir/sub_dir3 /home/user/Project_Src/Dir_B /home/user/Project_Src/Dir_B/Build i want to create a folder with... (2 Replies)
Discussion started by: dragon.1431
2 Replies

5. Shell Programming and Scripting

shell script - search a file and perform some action

hi, i have a service on unix platform, it will generate traces in a particular folder i want to check using shell script if traces exist, then perform some action else continue to be in loop. filename is service.tra can you please help? thanks (4 Replies)
Discussion started by: gauravah
4 Replies

6. Shell Programming and Scripting

How to access files from different directories and to perform search action in those files?

Hi, I want to access files from different directories (for example: /home/dir1/file1 , /home/dir2/file2 ...) Like this i have to access these files(file1, file2...). (3 Replies)
Discussion started by: bangarukannan
3 Replies

7. Shell Programming and Scripting

Script to monitor for new file with ext .err and size > 0 bytes and perform a action or command

Hi All, I need to create a script to monitor a dir for new files with ext .err and also it should b a non empty files. and perform a action or command . We have a new ETL application that runs on a linux server, every times a etl fails it creates a .err file or updates the existing .err... (4 Replies)
Discussion started by: MAKHAN
4 Replies

8. Shell Programming and Scripting

Perform an action if certain text exist in output (PERL)

Hello, I'm attempting to write a tool that checks an IP address for existing PTR records then if there are no PTR records does a ping to see if it response. Then if there is no response, it should print a message saying This is what I have so far. #!/usr/bin/perl $nxdomain =... (4 Replies)
Discussion started by: spartan22
4 Replies

9. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies
PON(1)								    Debian PPPD 							    PON(1)

NAME
pon, poff, plog - starts up, shuts down or lists the log of PPP connections SYNOPSIS
pon [ isp-name [ options ] ] poff [ -r ] [ -d ] [ -c ] [ -a ] [ -h ] [ isp-name ] plog [ arguments ] DESCRIPTION
This manual page describes the pon, plog and poff scripts, which allow users to control PPP connections. pon pon, invoked without arguments, runs the /etc/ppp/ppp_on_boot file, if it exists and is executable. Otherwise, a PPP connection will be started using configuration from /etc/ppp/peers/provider. This is the default behaviour unless an isp-name argument is given. For instance, to use ISP configuration "myisp" run: pon myisp pon will then use the options file /etc/ppp/peers/myisp. You can pass additional pppd options after the ISP name, too. pon can be used to run multiple, simultaneous PPP connections. pon takes the following command line options: -q --quick disconnect when ip-up finishes running. This function is only available to the root user. poff poff closes a PPP connection. If more than one PPP connection exists, the one named in the argument to poff will be killed, e.g. poff myprovider2 will terminate the connection to myprovider2, and leave the PPP connections to e.g. "myprovider1" or "myprovider3" up and running. poff takes the following command line options: -r causes the connection to be redialed after it is dropped. -d toggles the state of pppd's debug option. -c causes pppd(8) to renegotiate compression. -a stops all running ppp connections. If the argument isp-name is given it will be ignored. -h displays help information. -v prints the version and exits. If no argument is given, poff will stop or signal pppd if and only if there is exactly one running. If more than one connection is active, it will exit with an error code of 1. plog plog shows you the last few lines of /var/log/ppp.log. If that file doesn't exist, it shows you the last few lines of your /var/log/syslog file, but excluding the lines not generated by pppd. This script makes use of the tail(1) command, so arguments that can be passed to tail(1) can also be passed to plog. Note: the plog script can only be used by root or another system administrator in group "adm", due to security reasons. Also, to have all pppd-generated information in one logfile, that plog can show, you need the following line in your /etc/syslog.conf file: local2.* -/var/log/ppp.log FILES
/etc/ppp/options PPPd system options file. /etc/ppp/pap-secrets System PAP passwords file. /etc/ppp/chap-secrets System CHAP passwords file. /etc/ppp/peers/ Directory holding the peer options files. The default file is called provider. /etc/chatscripts/provider The chat script invoked from the default /etc/ppp/peers/provider. /var/log/ppp.log The default PPP log file. AUTHORS
The p-commands were written by Christoph Lameter <clameter@debian.org>. Updated and revised by Philip Hands <phil@hands.com>. This manual was written by Othmar Pasteka <othmar@tron.at>. Modified by Rob Levin <lilo@openprojects.net>, with some extensions taken from the old p-commands manual written by John Hasler <jhasler@debian.org>. SEE ALSO
pppd(8), chat(8), tail(1). Debian Project July 2000 PON(1)
All times are GMT -4. The time now is 07:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy