My continuing educational journey.

It was pointed out to me that at least procmail will lock the mail file whereas my script was not.  So I decided to see what it would take to add locking.

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?

I see the timed lock that uses:

 flock -w 10 100 || exit 1

Which will wait 10 sec to lock the file and if not then quit.

So how does that first example work?

thanks
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
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@lists.fedoraproject.org

Reply via email to