-c, --command command
Pass a single command to the shell with -c.
With a single command, we have:
flock --exclusive --timeout 5 mylockfile.txt --command myscript.sh
But how to pass several commands?
Invoke the default shell (sh
) or a specific shell (e.g. bash
) explicitly:
flock --exclusive --timeout 5 mylockfile.txt --command sh -c 'myscript1.sh; myscript2.sh; myscript3.sh'
Variables changed within the command are local to the shell instance.