- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: FTP Files using sysdate
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2011 02:49 AM
тАО05-05-2011 02:49 AM
Is it possible to ftp only those files which is 1 day old i mean sysdate -1. Is there any script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2011 03:13 AM
тАО05-05-2011 03:13 AM
Re: FTP Files using sysdate
if the latter, there is the -mtime option of find to accomplish this:
# find -type f -mtime 1 -print
look at the man page of find for more info
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2011 03:42 AM
тАО05-05-2011 03:42 AM
Re: FTP Files using sysdate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2011 09:07 AM
тАО05-05-2011 09:07 AM
Re: FTP Files using sysdate
AFAIK there really is no way of scripting an FTP xfer that needs to know the date of the remote file, unless the name of the file contains the date.
I'm assuming you want to go to some remote box via ftp and get files that were created yesterday.
You could maybe go there and get an ls -Rl listing, bring that back to your local host, parse it and get a list of files you want, then go back out to the remote site and get the file.
??
-klb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2011 09:31 AM
тАО05-05-2011 09:31 AM
Re: FTP Files using sysdate
Note that these files are exclusively used to ftp source and destination, and you don't do any other work in them. For exmaple,
/home/ftpuser/INPUT/
/home/ftpuser/OUTPUT/
Everything that you are now asking to do, like :
find /opt/application/work/files
is performed in your own shell script that is called by cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2011 10:17 AM
тАО05-06-2011 10:17 AM
Solution1. Your question leaves out details, so we must make numerous assumptions in order to answer.
Assumption 1: All files are already in a single directory on the source system
Assumption 2: You're referring to an entire 24 hour period from the execution of the script, not just files exactly 24 hours old, but any file created WITHIN the last 24 hours
Assumption 3: You're still growing as an admin and understanding the UNIX command set and the limitations of commands like ftp, and that's OK! That's why we enjoy this forum!
If the above assumptions are correct, then as an example, if you have 10 files in a single directory, 2 of which have been created in the last 24 hours, the following command might work without a script, but you might want to script this to provide error control and other things that the CLI cannot do on it's own:
[/home/parkrc/tmp]# ls -lrt
-rw-r--r-- 1 parkrc sys 203553 Mar 7 17:00 ntlock.new
drwxr-xr-x 4 parkrc sys 8192 Mar 16 11:25 Bonnie
-rw-r--r-- 1 root sys 61571 Mar 21 11:08 ts99
-rwxr-xr-x 1 root sys 462533 Apr 27 09:30 escsi_diag.out.gz
-rw-r--r-- 1 root sys 55676 Apr 27 09:30 fcddiag.out.gz
-rwxr-xr-x 1 root sys 466733 Apr 27 09:30 fclpdiag.out.gz
-rw-r--r-- 1 root sys 12686 Apr 27 09:30 syslog.log.gz
-rw-r--r-- 1 root sys 815 Apr 27 09:30 LMVinfo.out.gz
-rw-r--r-- 1 root sys 0 May 6 07:00 test1
-rw-r--r-- 1 root sys 0 May 6 11:04 test2
[/home/parkrc/tmp]# find . -mtime -1 -print |awk -F "/" '{print $2}' |grep [0-z]
test1
test2
(that verifies we're picking up the correct 2 files)
From here, whether using ftp OR sftp, you'll have these filenames ready to either put in a file list (>/tmp/flist) for use in your script. Various methods are available to setup a loop to pass each name to the "put" sub/ftp command. This is the stuff good admins are made of, so it's a great opportunity to stretch your wings here and learn some shell coding!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2011 12:24 AM
тАО05-07-2011 12:24 AM
Re: FTP Files using sysdate
If using put, you can simply use find(1) to collect a list and then script them in ftp as mentioned by Viktor.
If using get, you'll need to do a "ls" first and then parse the output, then feed it back into ftp as mentioned by klb.
>I am talking about the files created.
On Unix type systems, files don't have the creation date, only modification.