Locking files to queue script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux