The lock tag has no wiki summary.
20
votes
6answers
6k 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. ...
13
votes
4answers
10k views
What is a spinlock in Linux?
I would like to know about spinlocks in detail?
Could someone explain that to me?
12
votes
2answers
636 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 ...
11
votes
3answers
3k 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 ...
9
votes
2answers
21k 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" ...
8
votes
3answers
9k views
what is the difference between spin locks and semaphores?
What are the basic differences between spin locks and semaphores in action?
5
votes
4answers
786 views
How to make sure only one instance of a bash script runs?
A solution that does not require additional tools would be prefered.
3
votes
1answer
184 views
Locking in a shell script
I want to write a long-running shell script so that only one copy could be run at a time. If the script crashes, I want a new invocation of the script not to be stopped by a lock from the crashed ...
3
votes
2answers
1k 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
252 views
Lock CD/DVD drive (prevent eject)
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 ...
2
votes
1answer
419 views
Lock file from being edited or deleted
I have CentOS and cPanel installed. I want to lock certain files (e.g. .ftpquota) from being deleted through FTP. I tried to change the ownership to root:root or root:lock but it didn't work; neither ...
2
votes
3answers
709 views
Gedit won't save a file on a VirtualBox share: Text file busy
I have a text file that I can change using other applications (for example openoffice). But when I try to change and save it using gedit, I am getting error from gedit:
Could not save the file ...
2
votes
1answer
58 views
Can't install anything
I'm not able to install, update or do anything else with apt-get, aptitude, dpkg and so on.
The lock-file /var/lib/dpkg/lock exists from boot-time on. When I delete it and run apt-get update, it ...
2
votes
1answer
57 views
How to use lockstat.txt on Ubuntu 12.04?
I have Ubuntu 12.04 installed on my machine. I want to use lockstat. I have looked at Documentation/lockstat.txt but I am not getting how to use it, if possible please help me out.
I am working on a ...
1
vote
1answer
62 views
How /var/lib/dpkg/lock works?
/var/lib/dpkg/lock is file that holding a lock when "A package manager is working". But how this system works? I have /var/lib/dpkg/lock everytime when I have Linux working. When I use one of package ...
1
vote
1answer
1k views
How do you make a cross-process locking in Linux (C/C++)?
I need to make sure one process executes only in one instance at a time. On Windows you could use named mutex. But I have no idea what to use on Linux.
I think I've seen an approach were app creates ...
1
vote
1answer
1k views
Is there a better way to unlock a file than move and copy?
My organisation uses Debian Linux running Samba for office file servers. Users run Outlook for their email, which crashes fairly regularly and leaves the outlook.pst file locked.
Currently, our ...
1
vote
1answer
62 views
No lockfile creation in NFS setup
I recently set up a new fileserver for our research group. The old one was running SuSE linux and, although small harddrives and a slow machine, worked fine. The clients are mostly Gentoo machines ...
1
vote
1answer
665 views
How to trace file locks (per directory)
I'm quite new to Linux and I have not really a clue on how to do this.
I've got a directory and I'd like to monitor (output to shell) when a file inside that directory get's a file lock and when it ...
1
vote
0answers
42 views
Lock a script starting daemons
I'm run a script with cron:
*/10 * * * * flock -n /tmp/lock script
I have to make sure that only one instance of the script is running at the same time, and for that I'm using flock. The problem is ...
1
vote
1answer
113 views
How do I ensure that only one instance of my ksh script runs on Solaris using NFS? [duplicate]
Possible Duplicate:
What Unix commands can be used as a semaphore/lock?
I have read many similar post and the solution seems to be to use flock. flock does not exist on my system and I ...