Locking issue

Hi everyone,

I have got a requirement that, i need to check a specific folder,say /test/lock/ for few specific files, say *lock*, whether it has been locked or not.If any one of it is locked than i need to delete that file after a specific time, say after 10 minutes.

I never have worked on such type of program earlier.Can anyone please help me to create a program like this?

Thanks in advance.:slight_smile:

Regards
Susant

dir=/test
[[ -f  $dir/lock ]] && sleep 600  && rm -f ./tmp/lock

If the file /test/lock exists, sleep for 600 seconds then delete the file.

Just to point out the obvious, you mean "rm -f $dir/lock" at the end.

Thnnx sa lot for quick reply

Regards
Susant :slight_smile:

Hi Jim,

I have a similar requirement which is basically to detect whether a file ie being locked before I can go and modify it. Is there any possible and simple way that I can check that the file is not being locked by another process. thanks a lot.

Harby.