Sponsored Content
Top Forums Shell Programming and Scripting Compare log files and get latest Post 302337700 by edidataguy on Friday 24th of July 2009 04:59:25 PM
Old 07-24-2009
Quote:
Originally Posted by yogi90
#!/usr/bin/ksh
.
.
.
.
.
edidataguy if I use this it will always send a zero byte file to user which I do not want , I need to send the log file only when it gets created sometimes otherwise do not send anything
Please read my message fully.
I had said at the bottom:
Code:
If you want in your code check for [[ -s oldlog.log ]]

Use an "if" command and check if the file size is not 0.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare dates in a field and print the latest date row

Hi, I need a shell script which should find the latest date in the field of file and print that line only. For eg., I have a file /date.log Name Date Status IBM 06/06/07 close DELL 07/27/07 open DELL 06/07/07 open : : : From... (1 Reply)
Discussion started by: cvkishore
1 Replies

2. Shell Programming and Scripting

Retain 3 latest files

Guys, Please can you tell me how to retain 3 latest files in a directory and get rid of the rest ? Thanks very much Regards, Ganesh (6 Replies)
Discussion started by: kamathg
6 Replies

3. Shell Programming and Scripting

to compare latest logfile with the current running time of the script

how can i compare the latest log file with the current time.. consider i am running a script "a.sh" at 09:00 ( function of the script a.sh is to update the database ) this script is going to create logfile if the script is sucess in case of failure it is not going to create logfile.. ... (0 Replies)
Discussion started by: mail2sant
0 Replies

4. UNIX for Dummies Questions & Answers

To list only the very latest files

Hi, There are huge no of files in the directory. If i say ls -ltr it is taking too much time. i want to see only the files for Feb,2009. Please help. Thanks (3 Replies)
Discussion started by: venkatesht
3 Replies

5. Shell Programming and Scripting

Compare 2 log files

Hello, I am new here, so first of all I want say hello to everyone. I am newbie on script but you may be able to help me on this : I am on solaris (ksh) I need to compare 2 files (one_trash.log / two_arch.log) On the first file I've got like 1000 entries files name Ex of one_trash.log... (15 Replies)
Discussion started by: Aswex
15 Replies

6. Shell Programming and Scripting

Require compare command to compare 4 files

I have four files, I need to compare these files together. As such i know "sdiff and comm" commands but these commands compare 2 files together. If I use sdiff command then i have to compare each file with other which will increase the codes. Please suggest if you know some commands whcih can... (6 Replies)
Discussion started by: nehashine
6 Replies

7. UNIX for Advanced & Expert Users

Getting Latest files

Hai I wolud like to know how to get the latest files. ex: file_ssss_00 file_ssss_01 i need to get file_ssss_01 files only. (in Unix script) Please give some idea ... (2 Replies)
Discussion started by: raju4u
2 Replies

8. Shell Programming and Scripting

Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix?

I've been finding myself using a log file colorizer written in perl to reformat and colorize the output from many different programs. Mainly, however, I use it to make the output from "tail -f" commands more readable. The base perl script I use is based on "colorlogs.pl" available from the... (1 Reply)
Discussion started by: rcsteiner
1 Replies

9. Shell Programming and Scripting

Compare different String in Log Files

Hi Guys , sorry for my first post but a newbie here need some help on my simple scripts. I have some scripts below that count the job started and the job finished and is the job started and job finished equal ..then all job was successfully run and finished on that day. but sometime the was... (3 Replies)
Discussion started by: thermometer
3 Replies

10. Shell Programming and Scripting

Read latest log files and perform database insert

Hi Experts, I have a situation where I need to write a shell script to continuously monitor a log directory with multiple log files and perform following: 1. Read the latest log file continuously and grep "Success" OR "Failure" 2. As it capture either Success or Failure, it has to perform a... (1 Reply)
Discussion started by: rish_max
1 Replies
sv(8)							      System Manager's Manual							     sv(8)

NAME
sv - control and manage services monitored by runsv(8) SYNOPSIS
sv [-v] [-w sec] command services /etc/init.d/service [-w sec] command DESCRIPTION
The sv program reports the current status and controls the state of services monitored by the runsv(8) supervisor. services consists of one or more arguments, each argument naming a directory service used by runsv(8). If service doesn't start with a dot or slash and doesn't end with a slash, it is searched in the default services directory /etc/service/, otherwise relative to the current directory. command is one of up, down, status, once, pause, cont, hup, alarm, interrupt, 1, 2, term, kill, or exit, or start, stop, restart, shutdown, force-stop, force-reload, force-restart, force-shutdown. The sv program can be sym-linked to /etc/init.d/ to provide an LSB init script interface. The service to be controlled then is specified by the base name of the ``init script''. COMMANDS
status Report the current status of the service, and the appendant log service if available, to standard output. up If the service is not running, start it. If the service stops, restart it. down If the service is running, send it the TERM signal, and the CONT signal. If ./run exits, start ./finish if it exists. After it stops, do not restart service. once If the service is not running, start it. Do not restart it if it stops. pause cont hup alarm interrupt quit 1 2 term kill If the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, or KILL signal respectively. exit If the service is running, send it the TERM signal, and the CONT signal. Do not restart the service. If the service is down, and no log service exists, runsv(8) exits. If the service is down and a log service exists, send the TERM signal to the log service. If the log service is down, runsv(8) exits. This command is ignored if it is given to an appendant log service. sv actually looks only at the first character of these commands. Commands compatible to LSB init script actions status Same as status. start Same as up, but wait up to 7 seconds for the command to take effect. Then report the status or timeout. If the script ./check exists in the service directory, sv runs this script to check whether the service is up and available; it's considered to be avail- able if ./check exits with 0. stop Same as down, but wait up to 7 seconds for the service to become down. Then report the status or timeout. reload Same as hup, and additionally report the status afterwards. restart Send the commands term, cont, and up to the service, and wait up to 7 seconds for the service to restart. Then report the status or timeout. If the script ./check exists in the service directory, sv runs this script to check whether the service is up and avail- able again; it's considered to be available if ./check exits with 0. shutdown Same as exit, but wait up to 7 seconds for the runsv(8) process to terminate. Then report the status or timeout. force-stop Same as down, but wait up to 7 seconds for the service to become down. Then report the status, and on timeout send the service the kill command. force-reload Send the service the term and cont commands, and wait up to 7 seconds for the service to restart. Then report the status, and on timeout send the service the kill command. force-restart Send the service the term, cont and up commands, and wait up to 7 seconds for the service to restart. Then report the status, and on timeout send the service the kill command. If the script ./check exists in the service directory, sv runs this script to check whether the service is up and available again; it's considered to be available if ./check exits with 0. force-shutdown Same as exit, but wait up to 7 seconds for the runsv(8) process to terminate. Then report the status, and on timeout send the ser- vice the kill command. try-restart if the service is running, send it the term and cont commands, and wait up to 7 seconds for the service to restart. Then report the status or timeout. Additional Commands check Check for the service to be in the state that's been requested. Wait up to 7 seconds for the service to reach the requested state, then report the status or timeout. If the requested state of the service is up, and the script ./check exists in the service direc- tory, sv runs this script to check whether the service is up and running; it's considered to be up if ./check exits with 0. OPTIONS
-v If the command is up, down, term, once, cont, or exit, then wait up to 7 seconds for the command to take effect. Then report the status or timeout. -w sec Override the default timeout of 7 seconds with sec seconds. This option implies -v. ENVIRONMENT
SVDIR The environment variable $SVDIR overrides the default services directory /etc/service/. SVWAIT The environment variable $SVWAIT overrides the default 7 seconds to wait for a command to take effect. It is overridden by the -w option. EXIT CODES
sv exits 0, if the command was successfully sent to all services, and, if it was told to wait, the command has taken effect to all ser- vices. For each service that caused an error (e.g. the directory is not controlled by a runsv(8) process, or sv timed out while waiting), sv increases the exit code by one and exits non zero. The maximum is 99. sv exits 100 on error. If sv is called with a base name other than sv: it exits 1 on timeout or trouble sending the command; if the command is status, it exits 3 if the service is down, and 4 if the status is unknown; it exits 2 on wrong usage, and 151 on error. SEE ALSO
runsv(8), chpst(8), svlogd(8), runsvdir(8), runsvchdir(8), runit(8), runit-init(8) http://smarden.org/runit/ AUTHOR
Gerrit Pape <pape@smarden.org> sv(8)
All times are GMT -4. The time now is 12:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy