Using Cron to Copy files


Beginner here. I’m trying to understand how to use Cron. I’ve been going through the wiki and help pages. Will the following copy files from one folder to another every five minutes:

/5 * * * * cp -f /sourcefolder/.* /targetfolder

If so will this overwrite files? Thanks!


not tested, but you probably mean

/5 * * * * cp -f /home/USER/DOMAINNAME.COM/sourcefolder/.* /home/USER/DOMAINNAME.COM/targetfolder

I don’t know what your application is, but it seems simpler to just create /targetfolder as a link to /sourcefolder, meaning they always have the same contents.


Thanks for the reply. That was just an example. I want to be able to automatically change the theme of my wordpress blog according to the season and I was thinking if I overwrote the images and css. style sheet that would be the easiest way. Is the following the right code for once a year on the 21st of March?

0 0 21 3 * *

Thanks again.


0 0 21 3 *

You have one too many arguments.


Thanks, Wikipedia states there are six arguments with the last being optional. I thought I needed it to make the task repeat every year. Is it wrong to include it?


The wikipedia article appears to be addressing multiple implementations of cron, the debian implementation running at dreamhost does not use the sixth argument.

See also:


Thanks for clearing that up.