How to check if a script is writing to a log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check if a script is writing to a log
# 1  
Old 02-03-2011
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 script apends to it ? How can I check this?
# 2  
Old 02-03-2011
tail -f <log_file>

the above will give you the log latest updates. If it shows only last 10 lines and the log is not moving then no script is writing into this file.
# 3  
Old 02-03-2011
Hello and thanks for the reply. I know about tail, but I need something more general, cause I have loads of logs. Eg can I check if the file is open for writing by the script or something similar ?
# 4  
Old 02-03-2011
You could try lsof <logfile> if available on your platform.
# 5  
Old 02-03-2011
I'll check and let you know :-)
# 6  
Old 02-03-2011
after every run append the log file to one file then your log file data is saved and it will get update every time...
# 7  
Old 02-03-2011
lsof exists but unfortunatelly : sh: lsof: Execute permission denied.
I don't have root access therefore I cannot chmod lsof :-(
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

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

3. 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

4. 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

5. Shell Programming and Scripting

Help writing a script check log not update.

:wall:Dear All.:p 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. . . . Fri Jan ... (1 Reply)
Discussion started by: ooilinlove
1 Replies

6. 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

7. Shell Programming and Scripting

Linux script to check the informatica log

Hi, We are loading 100 + oracle tables using informatica. At the end of the run, we need to verify the informatica log to confirm the rows are loaded properly to target tables. There are so many detials included in the etllog. But,the part of the informatica log, linux script needs to look... (0 Replies)
Discussion started by: Maya_Pillai
0 Replies

8. 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

9. Shell Programming and Scripting

shell script for primary and standby DB archive log check

Hi All, OS:AIX 5.3 64 bits I would like the below script to send alert mail with the message - "Standby logs falling behind Primary" to xyz@yahoo.com Script ===== #!/usr/bin/ksh #----------------------------------------------------------------------------- # Use SQL*Plus to query... (1 Reply)
Discussion started by: a1_win
1 Replies

10. HP-UX

Check size and rotate log script.

Hi Can you suggest some perl script. My OS is HP-UX 11.11 I want to it into a cron job. Every night it will backup the file with that day's date and open a dummy file. Thanks Ash (3 Replies)
Discussion started by: ashishT
3 Replies
Login or Register to Ask a Question