Operating System - HP-UX
1751765 Members
5044 Online
108781 Solutions
New Discussion юеВ

Re: How can I keep a file busy

 
SOLVED
Go to solution
Hakki Aydin Ucar
Honored Contributor

How can I keep a file busy

I wanted to keep a file ;plain text file; busy so that I can monitor with fuser and cannot rm with an error "text file busy"
18 REPLIES 18
V. Nyga
Honored Contributor

Re: How can I keep a file busy

Hi,

you can try with editing it - with vi for example.

Volkmar
*** Say 'Thanks' with Kudos ***
Suraj K Sankari
Honored Contributor

Re: How can I keep a file busy

hi,
if you open a file in vi then you can't unmount that file system fuser will show devise is busy,
but
>>cannot rm with an error "text file busy"
This will not be possible because if a file is open in one session you can delete this file from other session.

Suraj
Venkatesh BL
Honored Contributor
Solution

Re: How can I keep a file busy

try this:

# cat exe1.c ;; program which just waits for input.
#include

int main(argc,argv)
int argc;
char **argv;
{
getchar();
exit(0);

/* NOTREACHED */
return 0;
}

# cc exe1.c -o exe1 ;;compile

# ./exe1& ;; run in background
[1] + Stopped (SIGTTIN) ./exe1&

# rm exe1 ;;now try to remove the file.
rm: exe1 not removed. Text file busy

#
Laurent Menase
Honored Contributor

Re: How can I keep a file busy

it just need to be a running executable.
Hakki Aydin Ucar
Honored Contributor

Re: How can I keep a file busy

vi a plain text file it is not possible to get error like text file busy cannot rm that . .

I think it is only in question for executables, not possible to reproduce for plain text ? Am I right ?
Laurent Menase
Honored Contributor

Re: How can I keep a file busy

Yes ,scripts can be removed while executing because they are not text file in the sens of process description where text is the code part.
Venkatesh BL
Honored Contributor

Re: How can I keep a file busy

Yes, as Laurent mentioned, your definition of 'Text file' is different from what kernel refers.
Michael Steele_2
Honored Contributor

Re: How can I keep a file busy

tail -f file & (* indefinite and in background - will have to kill -9 the process to close file *)
Support Fatherhood - Stop Family Law
Laurent Menase
Honored Contributor

Re: How can I keep a file busy

no tail -f will indeed keep it open, but as it is not a "text" -understand executable text and not plain text, and it is not executed -
it will not avoid rm to work on the file.