--On Thursday, April 13, 2017 12:18 PM -0400 Jonathan Kamens
<[email protected]> wrote:
> However, there is a race condition risk: since my script runs
> continuously and adds new IPs to hosts.deny as they are detected, it
> could end up trying to update hosts.deny at the same time as the other
> script. Both my script and the other one make their changes by creating
> a new version of hosts.deny and then renaming it into place, so
> hosts.deny will never end up getting corrupted; the worst that could
> happen is that an update from one of the two scripts could be lost.
man flock
Try something like this in your script:
# only allow one copy of script in here at a time
ME=`basename "$0"`;
LCK="${HOME}/${ME}.LCK";
exec 8>$LCK;
flock -x 8;
You'll want to adjust the name and location of the lock file, of course.
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Fail2ban-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fail2ban-users