Sponsored Content
Top Forums Shell Programming and Scripting Retry every ten seconds while lockfile present Post 302384133 by rrstone on Monday 4th of January 2010 06:13:37 AM
Old 01-04-2010
Hello ,
Common atomic operation on filesystem is mv .
Code :
"while [ -f $LOCK2 ] " will fail , eventually , some day under heavy stress with concurrent access .

Correct locking should be like this :

Code:
while [ 1 ];do
   mv  $COMMON  $PRIVATE
   if [ $? -eq 0  ];then 
      # critical section here
      # do the work and   release the lock 
      mv $PRIVATE  $COMMON
   else 
       #  bad luck 
       sleep 120
    fi
done

This code will work on almost any possible combinations ( NFS , AFS , GFS , OCFS etc )

Last edited by Franklin52; 01-04-2010 at 07:17 AM.. Reason: Please use code tags!
 

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
mkfs.gfs(8)						      System Manager's Manual						       mkfs.gfs(8)

NAME
mkfs.gfs - Make a GFS filesystem SYNOPSIS
mkfs.gfs [OPTION]... DEVICE DESCRIPTION
mkfs.gfs is used to create a Global File System. OPTIONS
-b BlockSize Set the filesystem block size to BlockSize (must be a power of two). The minimum block size is 512. The FS block size cannot exceed the machine's memory page size. On the most architectures (i386, x86_64, s390, s390x), the memory page size is 4096 bytes. On other architectures it may be bigger. The default block size is 4096 bytes. In general, GFS filesystems should not deviate from the default value. -D Enable debugging output. -h Print out a help message describing available options, then exit. -J MegaBytes The size of the journals in Megabytes. The default journal size is 128 megabytes. The minimum size is 32 megabytes. -j Number The number of journals for mkfs.gfs to create. You need at least one journal per machine that will mount the filesystem. -O This option prevents mkfs.gfs from asking for confirmation before writing the filesystem. -p LockProtoName LockProtoName is the name of the locking protocol to use. The locking protocol should be lock_dlm for a clustered file system or if you are using GFS as a local filesystem (1 node only), you can specify the lock_nolock protocol. -q Be quiet. Don't print anything. -r MegaBytes mkfs.gfs will try to make Resource Groups (RGs) about this big. Minimum RG size is 32 MB. Maximum RG size is 2048 MB. A large RG size may increase performance on very large file systems. If not specified, mkfs.gfs will choose the RG size based on the size of the file system: average size file systems will have 256 MB RGs, and bigger file systems will have bigger RGs for better perfor- mance. -s Blocks Journal segment size in filesystem blocks. This value must be at least two and not large enough to produce a segment size greater than 4MB. -t LockTableName The lock table field appropriate to the lock module you're using. It is clustername:fsname. Clustername must match that in clus- ter.conf; only members of this cluster are permitted to use this file system. Fsname is a unique file system name used to distin- guish this GFS file system from others created (1 to 16 characters). Lock_nolock doesn't use this field. -V Print program version information, then exit. EXAMPLE
mkfs.gfs -t mycluster:mygfs -p lock_dlm -j 2 /dev/vg0/mygfs This will make a Global File System on the block device "/dev/vg0/mygfs". It will belong to "mycluster" and register itself as wanting locking for "mygfs". It will use DLM for locking and make two journals. mkfs.gfs(8)
All times are GMT -4. The time now is 03:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy