How to copy today's file to remote host .

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
sub320
Level 1
Level 1
Posts: 5
Joined: Thu May 31, 2018 4:54 am

How to copy today's file to remote host .

Post by sub320 »

I have a directory ( no sub directory ) , there are many files in it with differnet creation day , there are many files will be update to this directory on and on .

if I want to write a script so that today's file will be scp to another host , how to do it ?

I know the command "find" can search today file and output the result and run scp , is it a good method to use find or is there other better command may do that ?


#find . -mtime -1 -type f
User avatar
coffee412
Level 6
Level 6
Posts: 1076
Joined: Mon Nov 12, 2012 7:38 pm
Location: Indiana, USA
Contact:

Re: How to copy today's file to remote host .

Post by coffee412 »

I would think using Rsync would be a good approach. It will sync directories for you.

Some further info and examples:

https://www.tecmint.com/rsync-local-rem ... -commands/
Ryzen x1800 Asus Prime x370-Pro 32 gigs Ram RX480 graphics
IceWarp 12.0.3 * Mint 18.3 * RAID 1/5 * OpenVPN * Linux since kernel 2.0.36
************* Get Your Linux on! ***************
Mattyboy
Level 6
Level 6
Posts: 1193
Joined: Thu Mar 26, 2015 2:17 pm

Re: How to copy today's file to remote host .

Post by Mattyboy »

Yeah +1 for rsync.

Code: Select all

rsync --help
Set up your script and add it to the crontab to automate the backup.

Code: Select all

crontab -e

Code: Select all

man crontab
User avatar
WharfRat
Level 21
Level 21
Posts: 13909
Joined: Thu Apr 07, 2011 8:15 pm

Re: How to copy today's file to remote host .

Post by WharfRat »

rsync would be the better method, but if you want to go with find then find ~/script -type f -newermt "2018-08-02" -exec scp '{}' username@ip_address:~/script/ \; will do it :wink:
ImageImage
Post Reply

Return to “Newbie Questions”