[ale] Only one process

scott scott at sboss.net
Fri Jun 4 21:16:37 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512


On Jun 4, 2010, at 8:49 PM, JK wrote:

> Doesn't anybody worry about race conditions any more?  How do you
> defend against multiple copies of this script running simultaneously?
> Of course, cron *shouldn't* ever do that...
> 
> flock(1) seems relevant:
> 
> http://linux.die.net/man/1/flock
> 
> -- JK

when I write scripts that I dont want to run in parallel.  I check for a /var/run/*.pid file related to the script and if the PID in it isnt mine, then I abort out. if the file isnt there, I create it with my PID.  And when the script exits it removes the file.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.12 (Darwin)

iQIcBAEBCgAGBQJMCaV4AAoJEF51inK7SsNs64cP/2c0izpZwfXqKUZmpiphgZQn
W9WEIroBGTjmg3ABfGpNgrW8wKrkIpC8EXRj80hpRaeNLJ8bo7XLLu9Js6GOUycQ
rM+WRZxkuwFf3jDVmPN2tLIjzCuORizIHtp+es7l+eBuoSNAhb+y5S+ZZ07zQBdX
RrpGgWLRHXOzySHIPQ0ZgedvaqGk4K+pBHjECzRVC+amcOUjJH7v9PDR+AnMWV0Z
CXD0Tin6joOeCLfpc9tDupFJqPXUo0UL3PyB6UUEiRL5WrkkO0KgxbcybH10GNlr
5VSX6KnqgDfkkLvs0LOh1c0+VUn7vos6a/I9Igk3FyKnY3BnxFE8I97T1bRrJQcQ
Q/yFRGVkUrBgW+DEs5jrwmU8hso1o3AT6ioCNmKlnKJZEEziKo+CTjkqQ11QONU9
H5Xd+LhrD0+E32qsSNiUGKPZ3Q2YyPT18hnsaTXw6248QAE6TICqFB6S4cBxy2qJ
J2PTgqQ1Hd9kK0Vag/LmwLW4WcSdfLpkEFgM7FesQRU1MHzJ95bIBDXlXUYvCISl
rbWlb+Uzpw4olqridG2006BixYA2xfo4tMvG7xwaCx4MobJ9eK29XxM8HvnBQREu
NdoXj5qXfmmbTYpGTjmNVRP6AvJi7i56jG/e0JwvsYyqQNPVtc+P/PPgKzXEAUru
o2q6LsN3PP11t1dYgcMt
=EgeK
-----END PGP SIGNATURE-----



More information about the Ale mailing list