Skip to content
Advertisement

Tag: flock

Unable to lock file linux

I’m trying to lock a file and obviously there is something I’m missing, because eventhough it seems it’s locked I can still access and edit it using vim editor. Locking file: Checking using lslocks: But still able to access it and edit using different terminal (different process I believe). I tried the solution with file descriptors here Linux flock, how

Why does flock removes existing text from a file?

So, I am trying to get an exclusive lock on a text file using Flock and a line of text to that file however while doing so it removes whatever text was there earlier. So if the file had let’s say and after running the script I am expecting something like instead, all I get is why would it behave

flock: -c requires exactly one command argument

We have multiple cronjobs running on our system. The problem is that we run them every hour, and therefore sometimes the cronjob didn’t finish and a new instance has started. Because of that, we wanted to use flock so the script only gets executed once. However, when I have this in my crontab or run it alone I’m getting the

Advertisement