Tech Support > Operating Systems > UNIX / Variants > [Q] need script which can check day and copy files to other location???
[Q] need script which can check day and copy files to other location???
Posted by aaa on December 20th, 2004


We have application every day will create bunch of files under a directory (e.g.
/apps/report). Does any one has script can do following:

1. read system date (today)

2. check files under directory (e.g. /apps/report) which create Yesterday

3. copy files to other location (e.g. /apps/backup)


Thanks.

Posted by Dave Hinz on December 20th, 2004


On 20 Dec 2004 10:51:33 -0800, aaa <mccdba@yahoo.com> wrote:
man date

man find

man cp

Seriously, this is like a 6-line script. Nobody there scripts?


Posted by Robert Harris on December 20th, 2004


Dave Hinz wrote:

find /apps/report -type f -ctime 1 | xargs cp /apps/backup

although "Yesterday" probably needs refining as a definition.

Robert

Posted by Dave Hinz on December 20th, 2004


On Mon, 20 Dec 2004 21:03:48 GMT, Robert Harris <robertdotfdotharris@blueyonder.co.uk> wrote:
Probably work, as far as it goes, but he needs to decide how files
are going to be handled. Same filenames? Keep old ones? Overwrite?
Delete old?

That too. 6 lines is probably padding it, but there needs to be
a bit of wrapping around the find.



Similar Posts