crontab to move/copy either on specific file or random file at date/time

4.9k Views Asked by At

I am bit clueless where to start. I am looking for a solution

a) copy a particular file from folder A/ to B/ @ fix day/time b) copy a random file from folder A/ to B/ @ fix day/time

Any hint how to start would be really appriciated

CI

1

There are 1 best solutions below

0
Sarath S Menon On

Copying a specific file from A to B can be achieved by appending a line to your crontab depending on the time you want it to run. The general syntax will be:

minute hour dayOfMonth month dayOfWeek (command to be executed)

In your case the command to be executed will be like:

cp /path/to/file/to/be/copied /path/to/destination

For eg.: If you want to copy the file at 3:35 PM(15:35) on 20th of November then your command will be like

35 15 20 11 * cp /path/to/file/to/be/copied /path/to/destination

Check out this wikipedia link for an excellent explanation on setting up cron jobs.