From: Lars Hecking <lhecking+u$e-net@nmrc.ucc.ie>
Subject: Re: How to lock file from shell?
Date: 1999/03/04 [thread overview]
Message-ID: <i7hfs1f2ba.fsf@tehran.nmrc.ucc.ie> (raw)
In-Reply-To: 36DBBF44.BC07B1AD@ev.co.yu
Nikola Milutinovic <Nikola.Milutinovic@ev.co.yu> writes:
> Hi all.
>
> Here is what I would like to do. I'm gonna create several account for in-bound
> FTP. User with USER/PASS for those account will be able to leave files on those
> account via FTP.
>
> Then I'll create one "pick-up" account. User with that USER/PASS will pick up
> files. There will be a cron job, which will transfer files from "in-bound"
> accounts to the "pick-up" account.
>
> Well, my problem is: how to detect that the file has been transferred?
>
> The idea of testing a lock on the file, looked promissing, but I have to do it
> from a shell script (zsh). "cp" doesn't care if the file is under a
> lock/writing. I wouldn't want to implement any kind of "heuristic behavior" - IF
> filesize unchanged for past 15 min THEN copy.
>
> Any ideas?
A tool called lockfile comes with procmail. Maybe this is what you're
looking for?
NAME
lockfile - conditional semaphore-file creator
SYNOPSIS
lockfile -sleeptime | -r retries |
-l locktimeout | -s suspend | -! | -ml | -mu | filename
...
...
EXAMPLES
Suppose you want to make sure that access to the file
"important" is serialised, i.e. no more than one program or
shell script should be allowed to access it. For
simplicity's sake, let's suppose that it is a shell script.
In this case you could solve it like this:
...
lockfile important.lock
...
access_"important"_to_your_hearts_content
...
rm -f important.lock
...
Now if all the scripts that access "important" follow this
guideline, you will be assured that at most one script will
be executing between the `lockfile' and the `rm' commands.
...
prev parent reply other threads:[~1999-03-04 5:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-02 5:00 How to lock file from shell? Nikola Milutinovic
1999-03-02 5:00 ` Yvonne & Oliver Maag
1999-03-03 5:00 ` Nikola Milutinovic
1999-03-02 5:00 ` Ken Pizzini
1999-03-03 5:00 ` Nikola Milutinovic
1999-03-02 5:00 ` Joe Durusau
1999-03-03 5:00 ` Nikola Milutinovic
1999-03-03 5:00 ` Joe Durusau
1999-03-04 5:00 ` Lars Hecking [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox