Hello all
im trying to make daemon that listen for incoming textiles
and then it will move them to defined directory now the daemon part is ok
but im stack on how to check of file is close and done copied to directory .
so i could process it and move it forward
tnx
or some other way? with out using fcntl?
look into 'man fuser' or 'man lsof'
so what will be the best way to check if file is still being copied?
i dont see any option with using the fuser
#!/bin/ksh
in_use=$(fuser -u /path/to/file/filename)
if [ ${#in_use} -gt 0 ] ; then
echo "file in use"
else
echo "file not in use"
fi
on sunos solaris when i do fuser -u myfile.txt
the output is :
myfile.txt:
what is wrong here?
pls read the 'man' pages first!!!!
These kind of "words" are strictly not permitted in the forum.
Moderators! Please --->
I have few objections with the above!
on the same node with two different sessions,
I ran the following
session I
>
while :
do
echo "a" > file1
done
session II
>
while :
do
fuser -u file1; echo $?
sleep 1
done
the output really alternates between being used -> not being used
from the man pages of fuser,
fuser returns a non-zero return code if none of the specified files is
accessed or in case of a fatal error. If at least one access has been
found, fuser returns zero.
Hi Aigles,
I tried your script, but it is always returning me the result as " File is available", though the file is still being written to. It is a large file which takes quite some time to get ready.
So how can I know when the file is completely ready?
Thanks again for you assistance
lsof (to my knowledge) isn't part of non-GNU coreutils. It would work just fine for this problem.
My version of the man page for fuser states "open files or active file structures"
meaning that until the data is actually physically written to disk, fuser could return 0.
Which is what you see. fuser is really meant more for sysadmin use than just playing with open files like lsof does.
Hi Jim,
when I run lsof, all I could get is the following:
lsof: WARNING: compiled for AIX version 5.1.0.0; this is 5.2.0.0.
So the next step would be to update my version for lsof for AIX 5.2.0.0 ??? Unfortunately at this stage there is no plan for any system updates and I am one of the developpers team, so any other workaoround solution please?
Thanks again.