bash cron flock screen
I am using cron to run a bash script periodically, and trying to use flock to prevent this script and the processes it creates from being run multiple times. The entry in crontab to run it every minute is: */1 * * * * flock -n /tmp/mylockfile /home/user/myscript.sh arg1 arg2 The problem is, myscript.sh spawns multiple screen sessions in detached mode, it contains for i in {1..3}; do screen -d -m ./mysubscript.sh arg3 done Running screen with "-d -m" as above starts screen in "detached" mode as forked process, but these processes do not inherit the lock from flock, so that every minute 3 new