Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File locking in Linux without changing permission 1

Status
Not open for further replies.

vsdpsingh

Programmer
Mar 8, 2011
32
0
0
IN
Hi all,
I have some application, which is using some file, but if in between user deletes that backend file then application can start giving error.
How can i prevent user from deleting/cutting/renaming/blocking of usage by other applications that file.
Due to some issues i cannot change the premission of particular file.
In linux is there any command that can lock/unlock the file? So when application is using the file then, that file is locked for other applications?? OR just prevent user to cut/delete the file.
Please help me out
Thanks in advance
 
You could experiment with flock... I've never tried it myself; but I suspect it only works with other flock-aware applications... see how you go?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
You need to get to the source of the problem and ask "why" does this other use have access to this file?

Do you not have access to the application configuration so that you can tell that app to put the file somewhere else so that this other user does not access the location of that file.

Assuming that this other user requires access to the file then you can provide a duplication of that file for this other user to access and destroy if he/she so wishes

Just ..

Code:
# tail -f <the_realfile.nnn> | tee -i /new/path/somenew_filename.nnn

Then let/tell this other user to access the copy not the source.

Good Luck.

Laurie.
 
thank you all
@tarn this is a better idea to put the file somewhere else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top