Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a statistical application which runs every minute and creates charts accordingly.

In order to make these charts available to other users, I need to copy the whole folder containing the charts and paste it to a shared folder where other users can see the contents.

How can I automate this process so that e.g each 5 minutes the files and folders are updated?

share|improve this question
perhaps you don't need to copy those files.... –  woliveirajr Oct 10 '12 at 14:36
add comment

3 Answers

up vote 3 down vote accepted

This sounds like something which could perhaps be perfectly solved with rsync. In its simplest form it can be called like this

rsync sourceFolder destinationFolder

Called in a crontab every 5 minute:

*/5 * * * * /usr/bin/rsync sourceFolder destinationFolder

For options, permissions, exlude of special files or directories see man rsync.

share|improve this answer
I would recommend rsync -au as the default options (preserve all attributes and only overwrite older files). –  Gilles Oct 10 '12 at 22:23
I agree Gilles, that is the way I use it too on my production systems. :). –  wolf Oct 11 '12 at 3:41
And to be sure that it does not mess up hardlinks and sparse-files: rsync -auVH. That became my current standard. –  Nils Oct 11 '12 at 20:10
add comment

Use a cron job, assuming you have permissions to add one.

crontab -e

0-59/5 * * * * cp -r folder1 folder2

You might want to use better flags on the cp, such as cp -ur to only update changed files.

share|improve this answer
@Julian.Thank you:) –  Hossein Oct 10 '12 at 9:56
add comment

Excuse me, but why you need the files to be copied there?

If the users are just opening / reading files and don't need to perform activities on them (like multiple users editing the same file, etc)... you could just make a link to the folder, couldn't you? And then, for every new file inside it, your users would have instantaneous access.

try it:

ln -s /original_folder/logs /shared_folder/logs

and avoid wasting space...

share|improve this answer
Some systems do not allow to link across filesystems (and follow the link), for instance Helios Ethershare. So if you perhaps have a published tree with a shared folder a copy could be neccessary. –  wolf Oct 11 '12 at 3:46
In addition to what wolf already said: In Apache-httpd you have to explicitly allow to follow symbolic-links if using such a construction in a web-server. It is off by default to avoid having access in areas where no user should have access to (even ro). –  Nils Oct 11 '12 at 20:12
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.