Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm run a script with cron:

*/10 * * * * flock -n /tmp/lock script

I have to make sure that only one instance of the script is running at the same time, and for that I'm using flock. The problem is that sometimes this script starts a daemon, in this case, the daemon blocks the following script executions.

I know a possible solution would be unlock the file at the end of the script, but is it possible do it directly in the cron command?

share|improve this question
if the script starts a daemon, does it get the daemon to go into the background and detach itself from it? i.e. does the script itself still complete? –  drone.ah Feb 16 '13 at 11:10
the script starts the daemon and exits, and I think detach itself from it. The script is a python script and uses subprocess.call() to start the daemon –  José Luis Feb 16 '13 at 18:06
documentation for call says that the process waits for the call to complete. If the daemon does not return immediately, that could be why you have this issue. Can you change the script to fork the daemon instead and see if that does it? –  drone.ah Feb 16 '13 at 19:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.