Sponsored Content
Full Discussion: Locking issue
Top Forums UNIX for Advanced & Expert Users Locking issue Post 302184401 by jim mcnamara on Friday 11th of April 2008 11:24:23 AM
Old 04-11-2008
Code:
dir=/test
[[ -f  $dir/lock ]] && sleep 600  && rm -f ./tmp/lock

If the file /test/lock exists, sleep for 600 seconds then delete the file.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

File Locking

Hi, Does anyone know what happens when two processes are simultaneously trying to write to a single file in UNIX (AIX)? Cheers (1 Reply)
Discussion started by: penfold
1 Replies

2. UNIX for Dummies Questions & Answers

locking problem

Hi... after unlock my computer from lock, all telnet windows which i opened previously are closing automaticaly... i hope u understand....plz give solution... (1 Reply)
Discussion started by: venkatramana
1 Replies

3. Linux

Locking around kmem_cache_destroy

Hi There, I want to make sure that kmem_cache_alloc is not called concurrently with kmem_cache_destroy on module exit and I want be able to use GFP_KERNEL for the kmem_cache_alloc calls. Would a read/write lock be good fro this purpose or is there another method I should be using? Regards,... (0 Replies)
Discussion started by: Brendan Kennedy
0 Replies

4. UNIX for Dummies Questions & Answers

Keyboard keeps locking up

First off, let me start by saying that I am a total rookie when it comes to Unix so I will do my best to explain the situation. BACKGROUND:We are running AIX and using a third party Inventory Management software called Acclaim. My main interface terminal is just a "dummy" terminal hooked up to... (1 Reply)
Discussion started by: sstaszak11
1 Replies

5. Shell Programming and Scripting

locking mechanism

I have a shell script. How can use some kind of locking mechanism to ensure that the script is not being executed by two people at the same time? (3 Replies)
Discussion started by: tjay83
3 Replies

6. Shell Programming and Scripting

Locking a script

Hello everyone Im sure this has been asked lots of times before, but after endless searching i cant find what i need. How can i make a bash script unreadable to all, including root, but still executable, im not worried about editing it again etc... , is there a way to convert it or something, i... (5 Replies)
Discussion started by: dave123
5 Replies

7. UNIX for Advanced & Expert Users

File locking

i am working on a device runnin on linux....i have configured the samba server in the device such that my windows PC can access a shared folder in the device. Also in the device i am runnin some programs which access the files in this shared folder. What i want to know is whether there is any way i... (1 Reply)
Discussion started by: abhinx
1 Replies

8. Programming

Locking issue with serial port

Hi, In my application,I need to monitor the devices connected through serial port in solaris sparc 9 OS.I used c and java code for it and I am able to do the same but the problem comes when I restart the system and the open my application and try to monitor it.but I m unable to monitor the... (2 Replies)
Discussion started by: smartgupta
2 Replies

9. Linux

filesystem locking issue on linux

hi, we are getting filesystem locking issue very frequently. we are using linux rhel 5.5. our filesystem type is gfs2 where we are facing locking issue and unix admin team reboots server to over come with this issue. suddenly we used to face slowness on server and server gets hung. after that... (1 Reply)
Discussion started by: anshu ranjan
1 Replies

10. Red Hat

Locking Down SFTP

Hi List, I'm sure this has been done before and there must be several ways to skin the cat on this topic. What I am trying to achieve is set up user accounts for use with SFTP based on the standard OpenSSH protocol. And I want to be able to lock them down so that they cannot browse outside of... (2 Replies)
Discussion started by: landossa
2 Replies
flock(3UCB)					     SunOS/BSD Compatibility Library Functions					       flock(3UCB)

NAME
flock - apply or remove an advisory lock on an open file SYNOPSIS
/usr/ucb/cc[ flag ... ] file ... #include <sys/file.h> int flock( fd, operation) int fd, operation; DESCRIPTION
flock() applies or removes an advisory lock on the file associated with the file descriptor fd. The compatibility version of flock() has been implemented on top of fcntl(2) locking. It does not provide complete binary compatibility. Advisory locks allow cooperating processes to perform consistent operations on files, but do not guarantee exclusive access (that is, pro- cesses may still access files without using advisory locks, possibly resulting in inconsistencies). The locking mechanism allows two types of locks: shared locks and exclusive locks. More than one process may hold a shared lock for a file at any given time, but multiple exclusive, or both shared and exclusive, locks may not exist simultaneously on a file. A lock is applied by specifying an operation parameter LOCK_SH for a shared lock or LOCK_EX for an exclusive lock. The operation paramerer may be ORed with LOCK_NB to make the operation non-blocking. To unlock an existing lock, the operation should be LOCK_UN. Read permission is required on a file to obtain a shared lock, and write permission is required to obtain an exclusive lock. Locking a seg- ment that is already locked by the calling process causes the old lock type to be removed and the new lock type to take effect. Requesting a lock on an object that is already locked normally causes the caller to block until the lock may be acquired. If LOCK_NB is included in operation, then this will not happen; instead, the call will fail and the error EWOULDBLOCK will be returned. RETURN VALUES
flock() returns: 0 on success. -1 on failure and sets errno to indicate the error. ERRORS
EBADF The argument fd is an invalid descriptor. EINVAL operation is not a valid argument. EOPNOTSUPP The argument fd refers to an object other than a file. EWOULDBLOCK The file is locked and the LOCK_NB option was specified. SEE ALSO
cc(1B), lockd(1M), chmod(2), close(2), dup(2), exec(2), fcntl(2), fork(2), open(2), lockf(3C) NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. Locks are on files, not file descriptors. That is, file descriptors duplicated through dup(2) or fork(2) do not result in multiple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock. Locks are not inherited by a child process. Processes blocked awaiting a lock may be awakened by signals. Mandatory locking may occur, depending on the mode bits of the file. See chmod(2). Locks obtained through the flock() mechanism under SunOS 4.1 were known only within the system on which they were placed. This is no longer true. SunOS 5.11 30 Oct 2007 flock(3UCB)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy