File not created?
m3ldis opened this issue · 1 comments
I'm just a little confused, please advise if I'm doing something wrong. My understanding is that flock should CREATE a file to lock if it doesn't exist, but nothing is ever created. From man page: "It locks a specified file or directory, which is created (assuming appropriate permissions), if it does not already exist."
I'm trying to only run a script from cron if a lock cannot be acquired in order to avoid running it if it is already running (because it creates incoming connections to a server).
I have this in crontab:
* 10 * * * /usr/bin/flock -n /tmp/somescript.lockfile sh /Users/me/somescript.sh
I'm on Mac OSX mojave, 10.14.6.
I'm surprised to hear that nothing is being created.
You'll notice we open the lockfile with O_CREAT
regardless of whether we open it shared or exclusive: https://github.com/discoteq/flock/blob/master/src/flock.c#L255
Think you could write up a little more reproducible of an example?