Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File not created? #28

Open
m3ldis opened this issue Mar 11, 2020 · 1 comment
Open

File not created? #28

m3ldis opened this issue Mar 11, 2020 · 1 comment

Comments

@m3ldis
Copy link

m3ldis commented Mar 11, 2020

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.

@josephholsten
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants