Skip to main content

Timeline for Correct locking in shell scripts?

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Dec 4, 2018 at 5:31 comment added Wildcard This has basic syntax errors demonstrating it was never tested. Even if the syntax errors are fixed, it will never work under any circumstances. See unix.stackexchange.com/a/485825/135943
Oct 5, 2011 at 17:39 comment added frogstarr78 @maxschlepzig to prevent multiple lines you can also change the arguments to grep, or additional "filters" (e.g. grep -v $$). Basically I was attempting to provide a different approach to the problem.
Oct 5, 2011 at 17:33 comment added frogstarr78 @maxschlepzig to handle multiple users running the script add euser= to the -o argument.
Oct 5, 2011 at 17:29 comment added frogstarr78 @maxschlepzig indeed sorry about the incorrect $! vs. $$
Oct 5, 2011 at 17:29 history edited frogstarr78 CC BY-SA 3.0
edited body
Oct 5, 2011 at 12:02 comment added maxschlepzig It also includes a race condition: if 2 instances execute the first line in parallel then none gets the 'lock' and both exit with status 6. This would be a kind of one round mutual starvation. Btw, I am not sure why you use $! instead of $$ in your example.
Oct 5, 2011 at 8:20 comment added maxschlepzig Hm, the ps checking code runs from within my_script? In the case another instance is running - does not running_proc contain two matching lines? I like the idea, but of course - you will get false results when another user is running a script with the same name ...
Oct 5, 2011 at 5:52 history answered frogstarr78 CC BY-SA 3.0