Maintaining file currency


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Maintaining file currency
# 1  
Old 01-25-2012
Maintaining file currency

I have a common data folder with files like x* which is accessed by 3 unix servers.


Now each server will try to pick one file form this folder and move it to its local folder.

How to maintain file concurrency in this case?I dont want the same file to be accessed by more than one process.
# 2  
Old 01-27-2012
Since no one is trying to answer, I will give it a try to see if it can fit your requirement

Assuming each server is consuming the files one at a time, we may be able to run 'cksum' on the files and take the modular to determine if the file is meant for a particular server to process.

Suppose you have 3 servers (server1, server2, server3). server1 will consume any file cksum%3==0, server2 will consum any file cksum%3==1, etc

For server1, this is the code to pick up the first file to process
Code:
ls -1 x* 2>/dev/null | xargs cksum | awk '$1%3==0{print $3;exit(0)}'

If you still want to use some form of locking mechanism, try 'flock' (managing lock from shell script)
# 3  
Old 01-27-2012
We need to know a lot more about the environment (Operating Systems, Shell etc.) and the process.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maintaining file structure

Hi guys, I am trying to store some output in a file and then compare it to another file. I am gathering information from 2 commands: cat /opt/jbin/server.log.tmp > A grep "ephemeral" /opt/jbin/log/server.log.2015-05-02-18 > B The contents of both file are the same. This means if I do a... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

2. Shell Programming and Scripting

Printf statement for currency conversion

hi all, I had my script as a=qw b=rter c=fdfd curency=1000 printf"${curency} $a $b $c" > filename can i have printf statement that can change the currency from 1000 to 1,000 like it should convert the number to currency format ..?(i.e for any number) (14 Replies)
Discussion started by: hemanthsaikumar
14 Replies

3. Shell Programming and Scripting

SSH file redirection is not maintaining format

Hi, I'm running a script which would ssh to various ssh-trust enabled servers and get a list of packages installed. The output of this command would be redirected to a file ssh -q $i 'rpm -qa --queryformat '%{NAME}\t\t,%{ARCH}\t\t,%{VERSION}-%{RELEASE}\t\t,%{INSTALLTIME:date}\n'|sed... (2 Replies)
Discussion started by: maverick_here
2 Replies

4. Red Hat

Copy certain file types recursively while maintaining file structure on destination?

Hi guys, I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash. I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also... (1 Reply)
Discussion started by: rockf1bull
1 Replies

5. Shell Programming and Scripting

Format Money/Currency (U.S.)

I have looked everywhere. Does bash have a money/currency format for output? Do I have to use awk or printf? Thank you (4 Replies)
Discussion started by: Ccccc
4 Replies

6. UNIX for Dummies Questions & Answers

Maintaining HOURLY backups

I have a system where i take hourly back-ups of the system.The script for maintaining full backup for the last 5 days is find /backup/server -type f -mtime +4 -exec rm -f {} \; works fine for keeping the files of some 5 days old. In the case of hourly backups.How do we write to keep... (2 Replies)
Discussion started by: ravi55055
2 Replies

7. Shell Programming and Scripting

AWK Currency Conversion

How can I use awk command to convert values to currency. For example I have a database like follows John:200 smith:300 kim:405 and want it to out put like this John $200.00 (3 Replies)
Discussion started by: 3junior
3 Replies
Login or Register to Ask a Question