Use a lock file, a semaphore, or any other queuing method. What have you tried so far yourself? Or is this homework? | [reply] |
- Do you really want to lock the whole directory, or just ensure one copy of a.pl is running at a time?
- Will the files always be created/overwritten on execution of a.pl, or can they be appended to?
- Will there be other programs/scripts/etc that create/write/append to these log files?
You could either use flock or use sysopen with O_CREAT|O_EXCL on a file a.pl.lck in that directory. Handling error conditions is left as an exercise to the writer.
| [reply] |
I want to lock the whole directory.
Yes the files will always be appended(if present) and created and written(if not present).
No there will be no other scripts that create/write/append to these log files.
| [reply] |