X

Copy files on Linux shell that have been modified or added within the last X minutes

Here is a short script that helped me to copy files that have ben modified within the last 60 minutes to a new directory. The script uses a combination of the find and cp commands, it has to be run inside the directory that contains the new files.  In this example, I will copy all files that have been modified within the last 60 minutes from /var/www to the directory /var/newfiles, you can replace the timespan or target directory in the script to match your reqzúirements.

First, enter the /var/www directory which contains the files:

cd /var/www

Then execute this command to find the latest files and copy them to /var/newfiles:

find ./ -type f -mmin -60  -exec cp -pf {} /var/newfiles/ \;

 

 

Till Brehm:
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings