10-13-2015
To check if a file is open and in use (logs are being written to it)
Hello Experts,
I need to write a shell script to check if a file is open and something is being written to it. I want to know how OS handles it. I checked with lsof command but it is not working. For a test I did this.
HTML Code:
while true; do echo `date` >>abc.txt; done
then I checked
lsof | grep -i /home/admin/abc.txt
It did not show any open process to me.
Yesterday when I tried the same thing, it once showed up i.e. I could see the output of
lsof command but then again it disappeared.
I also tried the same by opening a file through
vi but no luck.
I also want to know how system behaves for a file that is being open through vi, gedit etc and the one that is being appended through a loop or some script.
10 More Discussions You Might Find Interesting
1. Linux
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
$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
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 in unix
is there any built in command or function ? (1 Reply)
Discussion started by: mail2sant
1 Replies
5. Shell Programming and Scripting
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
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
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
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
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
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
PLDD(1) Linux User Manual PLDD(1)
NAME
pldd - display dynamic shared objects linked into a process
SYNOPSIS
pldd pid
pldd option
DESCRIPTION
The pldd command displays a list of the dynamic shared objects that are linked into the process with the specified process ID. The list
includes the libraries that have been dynamically loaded using dlopen(3).
OPTIONS
-?, --help
Display program help message.
--usage
Display a short usage message.
-V, --version
Display the program version.
EXIT STATUS
On success, pldd exits with the status 0. If the specified process does not exist, the user does not have permission to access its dynamic
shared object list, or no command-line arguments are supplied, pldd exists with a status of 1. If given an invalid option, it exits with
the status 64.
VERSIONS
pldd is available since glibc 2.15.
CONFORMING TO
The pldd command is not specified by POSIX.1. Some other systems have a similar command.
NOTES
The command
lsof -p PID
also shows output that includes the dynamic shared objects that are linked into a process.
The gdb(1) info shared command also shows the shared libraries being used by a process, so that one can obtain similar output to pldd using
a command such as the following (to monitor the process with the specified pid):
$ gdb -ex "set confirm off" -ex "set height 0" -ex "info shared"
-ex "quit" -p $pid | grep '^0x.*0x'
BUGS
Since glibc 2.19, pldd is broken: it just hangs when executed. It is unclear if it will ever be fixed.
EXAMPLE
$ echo $$ # Display PID of shell
1143
$ pldd $$ # Display DSOs linked into the shell
1143: /usr/bin/bash
linux-vdso.so.1
/lib64/libtinfo.so.5
/lib64/libdl.so.2
/lib64/libc.so.6
/lib64/ld-linux-x86-64.so.2
/lib64/libnss_files.so.2
SEE ALSO
ldd(1), lsof(1), dlopen(3), ld.so(8)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU
2017-09-15 PLDD(1)