Questions tagged [lock]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
64
votes
13answers
56k views

Correct locking in shell scripts?

Sometimes you have to make sure that only one instance of a shell script is running at the same time. For example a cron job which is executed via crond that does not provide locking on its own (e.g. ...
216
votes
9answers
628k views

How to get over “device or resource busy”?

I tried to rm -rf a folder, and got "device or resource busy". In Windows, I would have used LockHunter to resolve this. What's the linux equivalent? (Please give as answer a simple "unlock this" ...
26
votes
11answers
21k views

How to make sure only one instance of a bash script runs?

A solution that does not require additional tools would be prefered.
71
votes
3answers
80k views

What are pid and lock files for?

I often see that programs specify pid and lock files. And I'm not quite sure what they do. For example, when compiling nginx: --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ Can ...
30
votes
5answers
48k views

What is a spinlock in Linux?

I would like to know about Linux spinlocks in detail; could someone explain them to me?
11
votes
2answers
94k views

How to lock users after 5 unsuccessful login tries?

How to lock users after 5 unsuccessful login tries? I gathered a few distributions/versions to how to do it, but I can't test it. RHEL4: by adding the: auth required /lib/security/$ISA/...
4
votes
3answers
4k views

How to lock on Solaris 10?

On Linux I use flock lock command to execute a command with an exclusive lock. What is the standard operating system command of Solaris 10 to do the same in a shell?
3
votes
1answer
642 views

Check and Test Lock from other Process

I am trying to create a service wrapper (init.d script) around one of my favorite applications. The application creates both a PID and a lock file, and so I'm trying to use those to ensure that I can ...
30
votes
2answers
10k views

Does redirecting output to a file apply a lock on the file?

If I have a command $ ./script >> file.log that gets called twice, with the second call occurring before the first one ends, what happens? Does the first call get an exclusive lock on the ...
8
votes
3answers
23k views

Obtain exclusive read/write lock on a file for atomic updates

I want to have a file that is used as a counter. User A will write and increment this number, while User B requests to read the file. Is it possible that User A can lock this file so no one can read ...
4
votes
1answer
4k views

Lock CD/DVD drive (prevent eject) [duplicate]

On my laptop the eject button for the CD/DVD drive is placed in a very unfortunate position and I hit it a dozen times per day and the tray pops out. I found many solutions which seemed to work for ...
3
votes
1answer
14k views

NFS mount: Device or resource busy

I referred the following link, the solution works. How to get over "device or resource busy"? The above solution works when you are manually deleting the file. But I have a python script ...
2
votes
1answer
821 views

Does linux tar block write access to files

I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer. I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, ...
2
votes
1answer
1k views

lock screen session suspension in debian jessie

lock screen session suspension in debian jessie I just read of an issue that seemed similar to mine, and as I cannot comment yet and my problem is different I will ask my question outright. the ...
2
votes
1answer
554 views

Locking console when computer suspends/hibernates

In X I've used the following script (from here) to lock the computer with i3lock each time pm-suspend or pm-hibernate are invoked. /etc/pm/sleep.d/00screensaver-lock: #!/bin/sh # 00screensaver-...
0
votes
1answer
5k views

use of lockfile in script and it significance

I have a code in which below line is used due to which i got stuck.I have hunted the web but did not understand well.just got to know the basic set of info as below lockfile can be used to create one ...
0
votes
1answer
33 views

Can we tell if a command is being run by a process or not, by looking at the flock lock file alone?

Is util-linux's flock implemented based on flock() in Linux C API? Can we tell if a command is being run by a process or not, by looking at the lock file alone? I found that when a command guarded by ...
0
votes
1answer
663 views

Arch: safely save and restore pacman databases

I want to backup the pacman sync databases after an execution of pacman -Sy, creating "restore points" which pacman -Suu can use to reverse a failed system upgrade. Further background can be found ...