I have to keep copying files over from my ~/src to /home/httpd directory, which is a pain when I'm making front end changes. Is there a way I can have changed files sync automagically? -- and specifically only while I'm developing -- something I can turn on and off.
Although not automatic, once you are done doing modifications, use rsync:
You could even create an alias:
As I emphasize to everyone, before using this you should check out
What I would personally do is use a
This will make it a background job that you could kill at anytime. Just type
Alternatively, to add the command as a
To edit your crontab:
I am not entirely sure what your objective is, but a few suggestions that might be of some use:
Instant, on modification (save): If you want the files to be updated as soon as one is modified, I might ask why you don't just make your changes in /home/httpd and then once everything is to your satisfaction copy them back. The idea of a working directory for safeguards (or to prevent taking down your site with a bad edit) is negated if the changes are to be copied immediately.
Near-instant, on modification:
If for some reason, you wish to have your changes applied nearly instantly, on file modification (i.e. as soon as a file is saved, it gets copied over) then I would suggest looking into
On demand (not instant):
If you are looking to complete all your edits and then push the changes (which is what I expect you are looking for), then you have several options. I presume that the annoyance lies in determining what files were changed, and copying them from a variety of different directories.
One simple solution to this is to use
Version Control: The most effective solution, although, considerably more complex than rsync, is version control - for instance, Subversion. Basically:
While more difficult to setup, initially, this approach allows the greatest control, and will easily let you rollback changes, list the modified files, and see what changes (diffs) were made at each revision - you can also add a description to your changes with each commit.
Look at lsyncd. It uses inotify to get info about changes in files and sync them over rsync.