Timeline for Lock a bash script based on parameter?
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 25, 2022 at 17:49 | vote | accept | classicmusiclover | ||
| Oct 25, 2022 at 12:29 | comment | added | Chris Davies | @aviro a Linux kernel, sure. Can you confirm this for all UNIX operating systems? | |
| Oct 25, 2022 at 12:25 | comment | added | aviro | Those documentation had been out of date for a long time, but flock supports NFS since kernel version 2.6.12. | |
| Oct 25, 2022 at 12:18 | comment | added | Chris Davies |
@aviro depending on which set of documentation you read, and which OS you're running, flock may or may not work over NFS. Note that the question doesn't specifically reference Linux.
|
|
| Oct 25, 2022 at 12:15 | history | edited | Chris Davies | CC BY-SA 4.0 |
Apparently flock works on NFS. But some documentation still says it doesn't
|
| Oct 25, 2022 at 11:29 | comment | added | aviro | Why wouldn't it work with NFS? NFS does have a lock manager (NLM). | |
| Oct 25, 2022 at 10:29 | comment | added | Chris Davies |
@classicmusiclover well, yes. If you don't allow the program to end then it hasn't ended. SIGTSTP is catchable, if you are really concerned about this possibility
|
|
| Oct 25, 2022 at 10:26 | comment | added | classicmusiclover | This is pretty much what I need, but I am wondering is there any workaround on SIGTSTP (e.g. if user does CTRL+Z in the shell before finishing the 10seconds and then re-tries this, the lock is still there, so unless removing it manually it will not allow him to execute). | |
| Oct 25, 2022 at 10:08 | comment | added | Sotto Voce | Yes, I use this technique a lot. The advantage of using a subshell and locking the file descriptor is that my script doesn't have to explicitly unlock the lockfile. When the subshell exits, the unlock is automatic. | |
| Oct 25, 2022 at 9:13 | history | answered | Chris Davies | CC BY-SA 4.0 |