Sponsored Content
Top Forums Shell Programming and Scripting Retry every ten seconds while lockfile present Post 302384192 by rrstone on Monday 4th of January 2010 09:49:00 AM
Old 01-04-2010
flock on NFS ?
You should be very careful with flock on NFS .
Bad things happen when you use different Unixes and rely on flock .
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Enomem in Journal Retry Error

Hi, Does anyone seen this error before.. kernel: ENOMEM in journal_alloc_journal_head, retrying. I encounter this problem on IBM eServers where when the above error appears usually the machine is dead or hanged. Unless a hard reboot is been done. Is this something have to do with the memory... (1 Reply)
Discussion started by: killerserv
1 Replies

2. Shell Programming and Scripting

retry process in ftp

hi #!/bin/bash SERVER=10.89.40.35 USER=xyz PASSWD=xyz ftp -in $SERVER<<EOF user $USER $PASSWD mkdir PPL cd /path of remote dir lcd /path of local dir hash bin put <file name> bye <<EOF The above ftp script i have to schedule in crontab at a particular instance of time run daily.... (2 Replies)
Discussion started by: rookie250
2 Replies

3. Shell Programming and Scripting

Retry upon FTP failure

I am using the following code in a C Shell script to transfer files to a remote server: ftp -n logxx.xxxx.xxx.xxx.com <<DO_FTP1 quote user $user_name quote pass $password ascii put $js_file_name bin put $FinalZipFile quit DO_FTP1 This code works great except on those rare occasions... (8 Replies)
Discussion started by: phudgens
8 Replies

4. Shell Programming and Scripting

Shell Script to Retry and Exit

ok, so I'm trying to add a function to my local script that runs a command on a remote host. The reason why this is needed is that, there are other scripts that run different commands on the same remote host. so the problem is that many times there are multiple scripts being run on the remote... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

execute the shell script per ten seconds

hi, everyone. My want to execute the shell script below per 10 seconds PID=`pgrep java` if then /home/java/java fi crontab wouldn't help me. some one can give me suggestions?thanks ---------- Post updated at 07:29 AM ---------- Previous update was at 07:26 AM ---------- ... (6 Replies)
Discussion started by: AKB48
6 Replies

6. UNIX for Advanced & Expert Users

How to manipulate the conditions between every retry in wget?

Hi , When i hit the URL using WGET command ,it is retrying according to the number of retry we mentioned along with Wget command. my expectation : 1) If 1st try is failed and iam retrying again before 2nd retry i have to check for "xxxxxxx" entry in the log file. 2) If "XXXXXXX" entry is... (4 Replies)
Discussion started by: vinothsekark
4 Replies

7. Shell Programming and Scripting

Bash Lockfile Command

Hi, I am new to this forum, could any one please help me to understand the LOCKFILE command with an example and what exactly it is used for and how it is used. Thanks Reshu289 (4 Replies)
Discussion started by: Reshu289
4 Replies

8. Shell Programming and Scripting

If then else - Retry operation

I need to read a file line by line, then depending on the contents of each line, type in a code that will get written to an array. The problem I have is when I ask the user to confirm the input code, if it is wrong, how do i Return to ask again? Any thing I try increments the file to the next... (6 Replies)
Discussion started by: kcpoole
6 Replies

9. UNIX for Advanced & Expert Users

Semaphore - lockfile/flock

Hi, I have a process which can run one instance at a time. Currently we have multiple scripts trying to kickoff this process. I wanted to implement the semaphore mechanism to achieve this. I was going through few examples. The below code seems to be reasonable solution. ... (5 Replies)
Discussion started by: tostay2003
5 Replies

10. Solaris

Unrecovered read error No retry

We encountered these error 2 times(e.g. Solaris 10 with NetWorker installed) with in the month of August, but we couldn't pin point the root cause, it might be bad sector, bad cable or software incompatibility? Do you experience these issue or please share your understanding about this? Thanks... (0 Replies)
Discussion started by: B@S
0 Replies
flock(2)							System Calls Manual							  flock(2)

NAME
flock - Applies or removes an advisory lock on an open file SYNOPSIS
#include <sys/fcntl.h> int flock( int filedes, int operation ); PARAMETERS
Specifies a file descriptor returned by a successful open() or fcntl() function, identifying the file to which the lock is to be applied or removed. Specifies one of the following constants for flock(), defined in the fcntl.h file: Apply a shared lock. Apply an exclusive lock. Do not block when locking. This value can be logically ORed with either LOCK_SH or LOCK_EX. Remove a lock. DESCRIPTION
The flock() function applies or removes an advisory lock on the file associated with the filedes file descriptor. Advisory locks allow cooperating processes to perform consistent operations on files, but do not guarantee consistency (that is, processes may still access files without using advisory locks, possibly resulting in inconsistencies). You can use the flock() function to coordinate a file's lock status on local, CFS, and NFS file systems. The locking mechanism allows two types of locks: shared locks and exclusive locks. At any time multiple shared locks may be applied to a file, but at no time are multiple exclusive, or both shared and exclusive, locks allowed simultaneously on a file. A shared lock may be upgraded to an exclusive lock, and vice versa, simply by specifying the appropriate lock type. This results in the previous lock being released and the new lock applied (possibly after other processes have gained and released the lock). Requesting a lock on an object that is already locked normally causes the caller to be blocked until the lock may be acquired. If LOCK_NB is included in operation, then this will not happen; instead, the call will fail and errno will be set to [EWOULDBLOCK]. NOTES
Locks are on files, not file descriptors. That is, file descriptors duplicated using the dup() or fork() functions do not result in multi- ple 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. Processes blocked awaiting a lock may be awakened by signals. The flock() interface is not part of any UNIX standard. Therefore, if you are designing and writing applications to be portable across platforms, you should use the fcntl() file locking interface instead of flock(). RETURN VALUES
Upon successful completion, 0 (zero) is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
If the flock() function fails, errno may be set to one of the following values: The file is locked and the LOCK_NB option was specified. The filedes argument is not a valid open file descriptor. A signal interrupted the flock call. The operator is not valid. The lock table is full. Too many regions are already locked. The lock is blocked by some lock from another process. Putting the calling process to sleep while waiting for that lock to become free would cause a deadlock. RELATED INFORMATION
Functions: close(2), exec(2), fcntl(2), fork(2), open(2), lockf(3) delim off flock(2)
All times are GMT -4. The time now is 08:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy