Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automated copy of files to a different directory

Status
Not open for further replies.

spsilver

Technical User
Dec 10, 2001
5
US
Hi! Please pardon my simplistic question. I am a newby to Linux/Servers.

I am wondering the best way to accomplish the copy of files named mall.* from
/home/public_html/files/
to
/home/public_html/john

I need all the mall.* files copied daily at 10:00 am. There are about 9 files total.
mall.1 , mall.2 , mall.3, etc...

Someone have a script or other suggestion.. THANKS!
 
Hi,

The simplest is to use cron to trigger a script every day. The main config file is /etc/crontab and on a redhat system that is configured to automatically run all the scripts in the /etc/cron.daily directory at a fixed time (can't recollect what time that is at the moment). So you could just create a trivial script with a 'cp' command in it and place it in that directory. If you specifically need another time is also quite easy to do ... see --> .

Regards
 
Thank you. I understand CRON would be a way to make it run. Might you have a "trivial script" that I might alter?
Is it as simple as
cp /home/public_html/files/mall.* /home/public_html/john
?????????? Like an dos batch file?

Thanks again, Newby
 
Hi,



Absolutely as long as the second argument is a directory... If you put the following in a file and do a 'chmod +x filename' to make it executable then thats all you need.



#!/bin/sh

cp -p /home/public_html/files/mall.* /home/public_html/john





(the -p is for preserve attributes)



Test it by changing directory to the /etc/cron.daily directory and then doing :



./scriptname (i.e whatever name you gave it)



You can also test whats being copied with the -v flag :



cp -pv /home/public_html/files/mall.* /home/public_html/john



You could also use the -u flag to only update if the source is newer or does not exist at the destination.



Regards









 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top