How to FTP all newly created but the current open file?


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Java 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  
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')?
This User Gave Thanks to adurga For This Post:
# 3  
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.
This User Gave Thanks to Unbeliever For This Post:
# 4  
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.
This User Gave Thanks to indo1144 For This Post:
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #447
Difficulty: Medium
DebianDog is also Puppy Linux.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Tar file with newly created file

Hello guys thanks for this helpful forum. I'm new to scripting and doing a little script that dump a sql database with some extra files from a VM of the company I'm in, and create a tar archive to be saved on our serve. How can I have the tarball to be created with the files generated in the... (2 Replies)
Discussion started by: dquake
2 Replies

2. AIX

No iscsi available in newly created AIX wpar

AIX 7.1 New to WPAR, hopefully just missing something simple here. Creating the WPAR like this..... (The box where the WPAR is hosted does have an iscsi protocol device) mkwpar -h wpar08 -l -n wpar08 -N interface=en0 address=xxx.xx.xx.xxx netmask=255.255.255.0 -D devname=/dev/iscsi0 -D... (0 Replies)
Discussion started by: TomR
0 Replies

3. Shell Programming and Scripting

Find the file created on current date

Hi All, I'm trying to find a file which is created on current day.... I searched in unix.com and i found, below command. find /land/ -mtime -1 -type f -print | grep "FF_Member_STG.dat" The command checks if the file with name "FF_Member_STG.dat" is created today then exit else proceed. ... (3 Replies)
Discussion started by: ace_friends22
3 Replies

4. Hardware

Formatting a newly created lun

Hi , I have created one new lun in my SAN storage and make it visible to my HP servers , but the fdisk -l output is somehow confusing. Do not know what to do next ---------- fdisk -l /dev/sdo1 Disk /dev/sdo1 (Sun disk label): 64 heads, 32 sectors, 10238 cylinders Units =... (7 Replies)
Discussion started by: mishra.sankar
7 Replies

5. Shell Programming and Scripting

Copy an array to a newly created directory

hello everyone, I am new to perl script and trying to develop a script as follows. I am trying to Create an array for storing all file names. I am trying to copy $libs into "scratch". however i am unable to do so. Please suggest.. #!/usr/bin/perl use File::Copy; #use... (5 Replies)
Discussion started by: Rashid Khan
5 Replies

6. Solaris

Can't see Newly created LUN by SAN admin

hello, i am an oracle DBA and trying to scan a newly created LUN of 200 GB on fiber channel by SAN admin.we have solaris 10 and SANtoolkit is installed.i tried following to get the new LUN at my machine. go /opt/Netapp/Santoolkit/bin and then ./sanlun lun show but i see only the existing... (12 Replies)
Discussion started by: janakors
12 Replies

7. UNIX for Dummies Questions & Answers

how to open file and see newly added updates

Hi, I just forgot what command we can use to open a file, and then see its updates, I remember that there is an option -f ,but with what command :wall: Tx Trent (1 Reply)
Discussion started by: trento17
1 Replies

8. UNIX for Advanced & Expert Users

default size of a newly created folder

Hi all, In linux how to create a directory with specified size, so that it can be used only up to the mentioned size. Actually my question is, whether we can do directory quota in linux. mounting the directory in a partiton will do that, but do we have any other option... (1 Reply)
Discussion started by: anishkumarv
1 Replies

9. Shell Programming and Scripting

How to find the newly created directory

Hi, I need to create new directory by increasing the number by 1 of extracted lastly created directory. e.g. Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ become Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ Log\out_log_4\ Can anyone help how to do it in c-shell... (3 Replies)
Discussion started by: Andre_2008
3 Replies

10. Shell Programming and Scripting

How to keep appending a newly created file based on some keywords

Hi Friends, I have to create a new log file everyday and append it with content based on some keywords found in another log file. Here is what I have tried so far... grep Error /parentfolder/someLogFile.log >> /parentfolder /Archive/"testlogfile_error_`date '+%d%m%y'`.txt" grep error... (6 Replies)
Discussion started by: supreet
6 Replies

Featured Tech Videos