Sponsored Content
Top Forums Shell Programming and Scripting Need to script following a noisy log file which rolls over Post 302329609 by kshji on Monday 29th of June 2009 03:38:08 AM
Old 06-29-2009
Example how to control child process.
logreader is our logreader and mainlogreader controll subreaders.

Code:
#!/usr/bin/ksh
# logreader.sh
f=/var/log/crazy.log 

function look()
{
   tail -f $f | while read line
   do
        case "$line" in
                *ailure*) do_something ;;
        esac
   done
}
#--main---
look

And main process, control subreaders
Code:
#!/usr/bin/ksh
# mainlogreader.sh
f=/var/log/syslog.log 
child=""

function start
{
    ./logreader.sh >> somelogfile.log 2>&1  &
    #save childprocess pid
    child=$!
}

function restart
{
    # stop child process using signal 15 
    kill $child
    # wait child exit signal
    wait $child
    # restart
    start
}

function look
{
   tail -f $f | while read line
   do
        case "$line" in
                *"logfile turned over"*) restart ;;
        esac
   done
}

####################################
#MAIN
####################################
# start sub logreader
start
# start my log reading
look

And now start
./mainlogreader.sh
or background process
./mainlogreader.sh > log.txt 2>&1 &
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Log file for a Script

Oracle92 on solaris 8. We have a Truncate Script that runs every night to cleanup certain tables , so new data gets loaded into. This Script is run in Unix Shell script where i set Environment varibles, and things like that.. Now, how do i create a log file of the script , to see weather the... (3 Replies)
Discussion started by: vr76413
3 Replies

2. UNIX for Dummies Questions & Answers

Script for parsing details in a log file to a seperate file

Hi Experts, Im a new bee for scripting, I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies

3. Shell Programming and Scripting

log file script

I have a log which is configured as follows: date time code1 notes: code2 A monthly job is run based on information supplied from this log. The end of each monthly job is clearly indicated by a code within 'code1'. At this time someone is performing a less on the log, moving to the end,... (2 Replies)
Discussion started by: bwatlington
2 Replies

4. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

5. Shell Programming and Scripting

Script to monitor log file

Hi, Have written a script to monitor linux non standard log file based on line numbers, so each check store $otalinenum .. then in next check after 10 minutes it compre the current_total_line_num > last_total_line_num then it will parse the log file from last_total_line_num to... (0 Replies)
Discussion started by: Shirishlnx
0 Replies

6. Shell Programming and Scripting

Shell Script to grep Job File name and Log File name from crontab -l

Hello, I am new to shell scripting. I need to write a shell script where i can grep the name of file ie. .sh file and log file from crontab -l. #51 18 * * * /home/oracle/refresh/refresh_ug634.sh > /home/oracle/refresh/refresh_ug634.sh.log 2>&1 #40 17 * * * /home/oracle/refresh/refresh_ux634.sh... (1 Reply)
Discussion started by: guptra
1 Replies

7. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

8. Shell Programming and Scripting

Script to rotate file log

Hi Experts, I have script on crontab and give output quite large. I would like to know how to create rotate log when the size of log maximum 50MB if the test.log is 50MB then create test.0 Thanks Edy (2 Replies)
Discussion started by: edydsuranta
2 Replies

9. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies
DUENDE(8)							      duende								 DUENDE(8)

NAME
duende - run a child process as a daemon DESCRIPTION
duende makes a given child process a daemon. The standard output and standard error of the child process is logged via syslog() with a priority of LOG_ALERT. USAGE
duende [options] child_process [ arguments passed onto child ] DETAILS
When duende is invoked, it spawns two processes. In addition to spawning the daemonized child process, duende also spawns a process which reads and logs the standard output of the daemonized process. The parent process stays alive so as to monitor the daemonized process. duende requires a blank directory named /etc/maradns/logger to run. Should the parent duende process a HUP signal, duende will restart the child process. Should the daemonized or logging process received an untrapped HUP signal or exit with an exit code of 8, duende will restart the process. Should the daemonized or logging process exit for any other reason, duende will send the logger process a TERM signal and exit. Should the duende parent process receive a TERM or INT signal, duende sends all of its children TERM signals, then exits. The duende process must be started as the superuser; this is because Duende's intended child processes (maradns and zoneserver) need to bind to privileged ports, and because duende uses a setuid() call to change the user ID of the logging process to the user with ID 66. OPTIONS
Most of the above behaviour can be configured by command line arguments. -c|--chroot directory The log helper process will change its directory and root to this location. This defaults to /etc/maradns/logger . -i|--ident string The log helper process will use this string to identify the process when sending messages to syslog. This defaults to log-help . -p|--pid filename If this argument is present, the duende parent process will store its pid in this file. -u|--uid integer The log helper process will drop its user id to this. This value defaults to 66. -g|--gid integer The log helper process will drop its group id to this. This value defaults to 66. -r|--restart_on integer The log helper process will restart the child process if it exists with this status code. This defaults to 8. LOGGING
duende uses the syslog() facility to log the standard output of the program that it invokes. The name of the program (in other words, the "ident" given to openlog()) defaults to log-helper but can be overridden with the --ident argument. All messages created by the child process are sent to syslog() with a priority of LOG_ALERT and a "facility" of LOG_DAEMON (daemon.info in /etc/syslog.conf). Should duende itself encounter an error, it will send messages to syslog() with a priority of LOG_ALERT. Also, the directory /etc/maradns/logger, while used by duende, is not used to store any log messages. That is unless, for some reason, one configures syslog to store messages there. EXAMPLES
Using duende to start maradns, where the mararc file is /etc/mararc.2 duende maradns -f /etc/mararc.2 Using duende to start zoneserver, where the mararc file is /etc/mararc.4 duende zoneserver -f /etc/mararc.4 BUGS
Duende assumes that all of its children are well-behaved, eating their vegetables, going to bed when told, and terminating when receiving a TERM signal. SEE ALSO
maradns(8), syslog(3) http://www.maradns.org LEGAL DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. AUTHOR
Duende and this man page are written by Sam Trenholme. D Richard Felker III provided some invaluable assistance with the piping code which duende uses. January 2003 duende DUENDE(8)
All times are GMT -4. The time now is 08:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy