Using the find command to copy yesterday date only files
Hello. Newbie is too advanced a description for me when it comes to Unix script writing, so I do everything the hard way by using multiple 'single' line commands.
I am trying to copy off log files to an 'archive' folder, then compress them to preserve disk space. However, I want to add a cron job that would do this nightly for any newly created log files.
I most familiar with the 'Find' command. I want to use that to copy files created just yesterday, nothing older. Then I figure I will use another cron job to compress the newly added files.
I've seen many suggestions on this site but they either contain a specific date value ex: "Apr 14" or the command includes everything that is yesterday's date plus older.
Here is my starting command:
find ./ -type f -ctime +7 -exec cp -p {} ./archive/ \;
I've manned 'find', 'ctime' and 'mtime' and I can't find what I'm looking for.
Does anyone have an answer? Or know if this is possible? If not possible, can someone please offer a script solution?
Thanks!!
|