The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Open .zip file created in UNIX sam99 UNIX for Dummies Questions & Answers 5 07-04-2008 07:58 AM
Setting link to newly installed Java version harjitsingh SUN Solaris 4 05-28-2008 11:25 AM
Newly created files default group and write permissions goldfish UNIX for Dummies Questions & Answers 2 02-20-2008 06:39 PM
How to empty a file(already created) laknar Shell Programming and Scripting 4 07-04-2007 01:00 PM
file was created before 15 days ago. YoungBlood UNIX for Dummies Questions & Answers 1 03-02-2007 01:23 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2005
indianya indianya is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 2
Post How to FTP all newly created but the current open file?

An application running on HP-UX constantly generates new text log files ( I think using logpipe ). Any new file created requires to be ftp'ed to an offline server, however I want to make sure that the current file being written should not be transferred.
For examples consider the following files on HP-UX server that are transferred to an offline server for processing.

file1 - old already transferred at T1
file2 - old already transferred at T1
file3 - old already transferred at T1
file4 - new needs to be transferred at T2
file5 - new needs to be transferred at T2
file6 - new needs to be transferred at T2
file7 - new needs to be transferred at T2
file8 - new needs to be transferred at T2
file9 - file currently open by application for writing ( don't include this file for transfer at T2, this will be transferred at T3 when the file is close)

Also the script that ftp's the files run on the remote offline server. Is there a command that can be run from remote server that will help identify all the new files but prevent the current open file from getting transferred?

thanks
  #2 (permalink)  
Old 08-30-2005
adurga adurga is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 19
I doubt whether UNIX has built in commands for these requriements. I see two queries here.

1) 'Already FTPed files' not be FTPed again :- Two solutions 1) Record the timings of when ever FTP command runs. Then always pick the files later than last run FTP command. 2) If remote host has permission to move/rename the files then as soon as they got FTPed move/rename them to some other format other than FTP files format. But in real scenarios it is very unlikely that remote host would be having permissions to move/rename files.

2) Not to pick the current growing file:- Assuming only one file is open for writing at any time, why dont you just leave the latest file (ignore file 'ls -lrt | tail -1')?
  #3 (permalink)  
Old 08-30-2005
Unbeliever Unbeliever is offline
Registered User
  
 

Join Date: Jul 2005
Location: England
Posts: 183
You can check to see if any file has a particular file open using the lsof command.

lsof filename

produces no output if no process has that file open. If you're running on Solaris then you can also use the 'fuser' command in the same way.

Unfortunately these must both be run on the local server. So you must run them there or via 'trusted' rsh/ssh connections.
  #4 (permalink)  
Old 09-12-2005
indo1144's Avatar
indo1144 indo1144 is offline
Registered User
  
 

Join Date: Jun 2002
Location: Netherlands
Posts: 54
You could always use a "workaround" like this:
Code:
ls -lrt | tail -2 | head -1 | awk '{ print $9 }'
to find out the second oldest filename in a directory and FTP that file, leaving the currently open file alone.

Assuming no other files are written there, use "ls -lrt name*" as a filter otherwise.
Also assuming the logs are rotated at known intervals, you can use cron to schedule the FTP-ing.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0