- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to check the latest file in directory and r...
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
Forums
Discussions
Discussions
Discussions
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
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
02-08-2011 03:18 AM
02-08-2011 03:18 AM
Script to check the latest file in directory and rsync the file to other server
Required your suggestion in making a good script.
Scenario: Every day a file is coming from FTP server to a particular director, it contains the files with timestamp. and from here i have to copy the files to other server with cron set. using rsync
xxxxx_xxxx_xxxxxx_xxxxx.csv_20110207_100007_0566
The file name is same like xx_xx_xx_xx.csv.
Every time there is change in file timestamp , it copies to directory. and i have to copy to server.
Pls suggest .
Regards
Ali.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011 06:04 AM
02-08-2011 06:04 AM
Re: Script to check the latest file in directory and rsync the file to other server
It would seem that you can use the '--include=PATTERN' and perhaps the '--exclude=PATTERN' to copy only files matching your format. See the manpages for 'rsync'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011 08:30 AM
02-08-2011 08:30 AM
Re: Script to check the latest file in directory and rsync the file to other server
In this scenario there is no include or exclude, if you see the file name.
It is generated in the same manner.
How yo will calcluate the timestamp here.
Regards
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011 11:15 AM
02-08-2011 11:15 AM
Re: Script to check the latest file in directory and rsync the file to other server
RSYNC already has the smarts to "rsync" only changed files. See it's syntax/guide.
Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011 11:18 AM
02-08-2011 11:18 AM
Re: Script to check the latest file in directory and rsync the file to other server
Favourite Toy:
AMD Athlon II X6 1090T 6-core, 16GB RAM, 12TB ZFS RAIDZ-2 Storage. Linux Centos 5.6 running KVM Hypervisor. Virtual Machines: Ubuntu, Mint, Solaris 10, Windows 7 Professional, Windows XP Pro, Windows Server 2008R2, DOS 6.22, OpenFiler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2011 12:11 AM
02-09-2011 12:11 AM
Re: Script to check the latest file in directory and rsync the file to other server
Like from today i want to send only latest file to the destination.
NOTE : Every day file name is changed.
and i dont want all files to copy on destination servers
Regards
Ali.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2011 06:34 AM
02-09-2011 06:34 AM
Re: Script to check the latest file in directory and rsync the file to other server
> The files names are not same. and i dont want to copy the whole files to the destination. Like from today i want to send only latest file to the destination.
If this is as simple as fetching the newest file in a particular directory, you don't need 'rsync'. You could do something like this:
Create or update the timestamp of a reference file in another directory every time your script runs *and* FTP's a file. You simply do this with 'touch'.
When your FTP script is launched, look for the most recent file in the directory (with an 'ls -1t|head -1') and if that file's modification timestamp is newer than that of the reference file, FTP it and update the reference file timestamp to that of the file just moved. You can use tests like 'if [ ${myfile} -nt ${reffile} ]; then ...'. If the most recent file isn't newer than the reference file, exit without further processing.
Regards!
...JRF...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2011 02:46 AM
02-10-2011 02:46 AM
Re: Script to check the latest file in directory and rsync the file to other server
So its working....
Regards
Ali.