Help writing a script check log not update.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help writing a script check log not update.
# 1  
Old 01-06-2011
Wrench Help writing a script check log not update.

SmilieDear All.Smilie

How to check log size every 10min. by script (not crontab)
if log size not change with alert "Log not update"

My Path :: /usr/home/logical/mono/log/tplink/
My Log :: mono11_tplink.log , mono12_tplink.log , etc

I want oup put.
EX. if log not update.
Code:
.
.
.
Fri Jan  7 20:30:00
mono11_tplink.log it ok.
mono12_tplink.log it ok.

Fri Jan  7 20:40:00
mono11_tplink.log it ok.
mono12_tplink.log it ok.

Fri Jan  7 20:50:00
mono11_tplink.log not update. Pls Check Service.
mono12_tplink.log it ok.

Fri Jan  7 21:00:00
mono11_tplink.log not update. Pls Check Service.
mono12_tplink.log it ok.


Fri Jan  7 21:10:00
mono11_tplink.log it ok.
mono12_tplink.log it ok.
.
.
.
.
Fri Jan  7 23:00:00
mono11_tplink.log it ok.
mono12_tplink.log log not update. Pls Check Service.

Thanks for any help guys, I am new to this and feel lost.SmilieSmilie
# 2  
Old 01-07-2011
Java A shell script for the job

*edited to use the suggested filenames/times/locations

I should totally do v2.0 with colours and stuff...

Code:
#! /bin/bash

logFiles="mono11_tplink.log mono12_tplink.log"
logLocation="/usr/home/logical/mono/log/tplink/"
sleepTime=600

failMessage="UNCHANGED, pls check service"
successMessage="ok"

arr=($logFiles)

arrlen=${#arr[@]}
arrcount=()

date
for ((count=0; count<arrlen; count++)) ; do
    arrcount[$count]=`wc -l < $logLocation${arr[$count]}`
    echo "${arr[$count]} starts with ${arrcount[$count]}"
done
echo

while [ "e" == "e" ] ; do #hacked infinite loop
    sleep $sleepTime
    date
    for ((count=0; count<arrlen; count++)) ; do
        nc=`wc -l < $logLocation${arr[$count]}`
        echo -n "${arr[$count]} "
        if [ $nc == ${arrcount[$count]} ] ; then
            echo $failMessage
        else
            arrcount[$count]=$nc
            echo $successMessage
        fi
    done
    echo
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing script to log

Hi, I have a shell script which contains echo 'hello' >> $logfile while executing my script i want the hello should be written in log file and also hello should be printed. Thanks in Advance (4 Replies)
Discussion started by: pracheth
4 Replies

2. Shell Programming and Scripting

Check log file size every 10 minute. Alert if log not update

How to check log size every 10min. by script (can use crontab) if log size not change with alert "Log not update" Base run on SunOS 5.8 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise logFiles="log1.log log2.log" logLocation="/usr/home/test/log/" Out put. Tue Jan 31... (3 Replies)
Discussion started by: ooilinlove
3 Replies

3. Shell Programming and Scripting

Writing a script to run weekly/monthly - check for weekday or day-of-the-month

Hi all, I currently have a UNIX file maintenance script that runs daily as a cron job. Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis. To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Discussion started by: newbie_01
1 Replies

4. Shell Programming and Scripting

Need help in writing a script that do internal grep on a log file..and extract acct no's from it..

I need to write a script, which takes the input a log file and create output file with acct no's line by line from selected records with text like (in red) : 18:51:18 | 217863|Acct 0110855565|RC 17608| 16 Subs| 1596 UsgRecs| 2 Secs| 430 CPUms| prmis2:26213 <MoveUsage d aemon needs to run... (7 Replies)
Discussion started by: rkrish
7 Replies

5. Shell Programming and Scripting

help with script Alert log not update every time.

:p Hello :) This is my script . This check log file size every 1 minute. Credit code https://www.unix.com/shell-programming-scripting/151723-help-writing-script-check-log-not-update.html #! /bin/bash logFiles="log1.log log2.log" logLocation="/usr/home/test/log/" sleepTime=60 ... (8 Replies)
Discussion started by: ooilinlove
8 Replies

6. Shell Programming and Scripting

Writing a UNIX script from LOG to provide return code.

Folks - Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX... (4 Replies)
Discussion started by: sk72
4 Replies

7. Shell Programming and Scripting

How to check if a script is writing to a log

Hello, I have various scripts that writes to logs ( >> ) in different directories. I have create a script to automatically check different direcories for different errrors. However I do not want to remove logs if a script is still writing to a log. Is the log file opened for writing when the... (7 Replies)
Discussion started by: drbiloukos
7 Replies

8. UNIX for Dummies Questions & Answers

Check who is writing to a file? (pid)

Hello, is there a way to check who is writing to a file? (pid) Like someone starts a ftp transfer, is uploading a file and I'd need to know which pid is actually writing to it. Or is there a way to check which file a process is currently accessing? Greetings and thanks for all your... (4 Replies)
Discussion started by: TehOne
4 Replies

9. Shell Programming and Scripting

Script to check file update on ftp server

Hi everybody, Is there a way to do a stat of files on a ftp server? I have a database which is populated by the contents of these files. I want to setup a crontab to check if there has been an update to these files. If the file has been updated I will download it and then update my database. ... (2 Replies)
Discussion started by: z1dane
2 Replies

10. Shell Programming and Scripting

Linux: Writing a tricky script to check connectivity

So, first and foremost, I'm having issues with my internet connection. Periodically, the connection drops across the network. The fix is simple enough: restart the modem. However, this gets old when the connection dies out every hour. I can hit my surfboard on 192.168.100.1, and navigate to a... (5 Replies)
Discussion started by: kungfujoe
5 Replies
Login or Register to Ask a Question