Sponsored Content
Top Forums Shell Programming and Scripting To check if a file is open and in use (logs are being written to it) Post 302957592 by Scrutinizer on Tuesday 13th of October 2015 06:17:28 AM
Old 10-13-2015
Your loop constantly closes and opens the output file for append, so whether you see something with lsof becomes a race condition.

Instead try:
Code:
while true; do echo `date` ; done >abc.txt

or to append:
Code:
while true; do echo `date` ; done >>abc.txt

In both cases the output file is opened once and kept open the whole time for the duration of the loop.

Last edited by Scrutinizer; 10-13-2015 at 07:23 AM..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Linux

check written data

I'm using growisofs to write DVD, e.g. $ growisofs -Z /dev/dvd -V "Personal Data, `date +"%b, %d %Y"`" -R -J /mnt/d/* How can I test whether data was written correctly? md5sum or so? (0 Replies)
Discussion started by: Hitori
0 Replies

2. UNIX for Dummies Questions & Answers

restrict data from getting written to Logs

$SYBASE/bin/isql -U $DB_USERID -S $DB_SERVER << ! >> $OUTFILE `echo $DB_PASSWD` use $db go Print " The processing" go ! # Extract data to file echo $DB_PASSWD | $SYBASE/bin/bcp $WRK_DB..open out $CONV_DIR/open".csv -t\, -c -U $DB_USERID -S $DB_SERVER -b 1000 | tail -3 I am able to... (0 Replies)
Discussion started by: w020637
0 Replies

3. Shell Programming and Scripting

avoid open file to check field.

Hi Everyone, # cat a.txt 94,aqqc,62345907, 5,aeec,77, # cat 1.pl #!/usr/bin/perl use strict; use warnings; use Date::Manip; open(my $FA, "/root/a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\,/, $_); if (index($tmp, "qq") ne -1) { ... (4 Replies)
Discussion started by: jimmy_y
4 Replies

4. Shell Programming and Scripting

How to check whether logs are updating or not?

how to check whether logs are updating or not in unix is there any built in command or function ? (1 Reply)
Discussion started by: mail2sant
1 Replies

5. Shell Programming and Scripting

Lots of logs to move....don't remove if open

I have a ksh script that currently moves a day's worth of log files (about 15,000) files to a different directory. The issue is that about 100 of these files are still open for write when this happens. I need an efficient way to ensure that these files aren't open without doing an lsof on each... (7 Replies)
Discussion started by: nestafaria
7 Replies

6. Solaris

logs to check

Hi all i want to know what are the logs we need to check when the server is down and how to resolve to make server UP? please help me with this (8 Replies)
Discussion started by: vkav
8 Replies

7. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

8. Debian

Logrotate truncated my log files to 0 bytes and no logs are written

Hi, Yesterday I installed and configured logrotate on my Debian machine. I was expecting this to run at 06:25 in the morning and it actually did. All my old logs were compressed and zipped but the new logs were all with size equal to 0 bytes. Processes, while still running ok, they were not... (2 Replies)
Discussion started by: pmatsinopoulos
2 Replies

9. Shell Programming and Scripting

Need to check logs

I have nearly 25+ tail commands which we need to verify the logs if there is any errors on current or previous date with time. I need this to be automate and send email to me with details. Please help me on this. (5 Replies)
Discussion started by: Nasir HussainSM
5 Replies

10. UNIX for Beginners Questions & Answers

How to check if a file is open in editor?

Hi there! I'm developing a program that allows the user to open and edit files using both an editor and the terminal. Once the user has finished editing the file an update is sent to the logbook that compares the file before and after it was edited - this can only be done if the file is closed (I... (23 Replies)
Discussion started by: cherryTango
23 Replies
WNPP-CHECK(1)                                                 General Commands Manual                                                WNPP-CHECK(1)

NAME
wnpp-check - check if a package is being packaged or if this has been requested SYNOPSIS
wnpp-check package ... wnpp-check --help|--version DESCRIPTION
wnpp-check downloads the lists of packages which are listed as being packaged (ITPed) or for which a package has been requested (RFPed) from the WNPP website and lists any packages supplied on the command line which appear in those lists. Note that WNPP, and therefore wnpp-check's output, is source package based. OPTIONS
--help, -h Show a summary of options. --version, -v Show version and copyright information. SEE ALSO
http://www.debian.org/devel/wnpp EXIT STATUS
0 None of the packages supplied has an open ITP or RFP 1 Either an error occurred or at least one package supplied has an open ITP or RFP AUTHOR
wnpp-check was written by David Paleino <d.paleino@gmail.com>; this man page was written by Adam D. Barratt <adam@adam-barratt.org.uk> for the devscripts package. wnpp-check was originally based on wnpp-alert, which was written by Arthur Korn <arthur@korn.ch> and modified by Julian Gilbey <jdg@debian.org> for the devscripts package. Both scripts are in the public domain. DEBIAN Debian Utilities WNPP-CHECK(1)
All times are GMT -4. The time now is 05:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy