On 5/11/20 2:13 PM, Robert Moskowitz wrote:
I found https://www.putorius.net/lock-files-bash-scripts.html, and part
of it is not making sense to me.
The following is suppose to be an example of making a script waiting
indefinitely for the an earlier instance to complete:
#!/bin/bash
exec 100>/var/tmp/testlock.lock || exit 1
flock 100 || exit 1
echo "Doing some stuff…"
echo "Sleeping for 30 seconds…"
sleep 30
I get the exec line's exit 1: If you can't get the file descriptor,
something is wrong and exit.
But the next line does not make sense. If you can't lock exit? How is
that indefinite?
No, that is if the flock command throws an error, then exit. Otherwise,
it waits forever until it can lock the file.
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx