3 Tighten up this solution. For small sync's, syncing at a minute resolution should be sufficient. Mention rsync -z.
source | link

One quick and dirty waysolution to do this would be to put a call in the user crontab to rsync the folder in question that is portable across UNIX platforms (not specific to the targetOSX, but may be used on a periodic basisHP-UX, and becauseSolaris, Linux, etc.) is to call rsync doesn't do much whenfrom the folders are actually IN SYNCuser's crontab, you shouldn't noticeand let rsync's folder synchronization logic itself determine if the periodic folder comparisonshas been changed or not. Of course, if that sounds like too much processing, One refinement to using this portable solution is to wrap the call to rsync could be wrapped with a Perl script that simply maintainsdate test between a touched date stamp file: only perform (actually its modification time) and the rsync ifmodification time of the source folder has a newer date than the touched flag filethat is to be synced, then update the touched flag file ifbut this is not necessary unless the folders to be synced are very large (deep and/or wide). A single folder was rsync'dwith several subfolders is ideal for this solution.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check everyat a minute with the following crontab entrypolling interval is:

# run sync every minute:
* * * * * /usr/bin/rsync -avavz $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

That should do it for the quick and dirty case - in other words, the folders will be kept up-to-date within a minute of making a change. Check the ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once correct operation has been determined, change ">>" to ">" to at least log the most recent rsync status.

Another pointer is that the -z switch to rsync should be used when syncing over a network. The -z switch will cause compression to be used for the network file transfers. When using rsync to sync between folders on filesystems local to a server, the -z switch may usually be omitted.

Note about using the crontab:

If you cannot edit your crontab with:

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.allallow does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.

One quick and dirty way to do this would be to put a call in the user crontab to rsync the folder in question to the target on a periodic basis, and because rsync doesn't do much when the folders are actually IN SYNC, you shouldn't notice the periodic folder comparisons. Of course, if that sounds like too much processing, the rsync could be wrapped with a Perl script that simply maintains a touched date stamp file: only perform the rsync if the source folder has a newer date than the touched flag file, then update the touched flag file if the folder was rsync'd.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check every minute with the following crontab entry:

# run sync every minute:
* * * * * /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

If you cannot edit your crontab with:

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.all does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.

One quick and dirty solution to this question that is portable across UNIX platforms (not specific to OSX, but may be used on HP-UX, Solaris, Linux, etc.) is to call rsync from the user's crontab, and let rsync's folder synchronization logic itself determine if the folder has been changed or not. One refinement to using this portable solution is to wrap the call to rsync with a date test between a touched file (actually its modification time) and the modification time of the folder that is to be synced, but this is not necessary unless the folders to be synced are very large (deep and/or wide). A single folder with several subfolders is ideal for this solution.

An entry for the crontab that will perform the "quick and dirty" case at a minute polling interval is:

# run sync every minute:
* * * * * /usr/bin/rsync -avz $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

That should do it for the quick and dirty case - in other words, the folders will be kept up-to-date within a minute of making a change. Check the ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once correct operation has been determined, change ">>" to ">" to at least log the most recent rsync status.

Another pointer is that the -z switch to rsync should be used when syncing over a network. The -z switch will cause compression to be used for the network file transfers. When using rsync to sync between folders on filesystems local to a server, the -z switch may usually be omitted.

Note about using the crontab:

If you cannot edit your crontab with:

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.allow does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

2 deleted 6 characters in body
source | link

One quick and dirty way to do this would be to put a simple Perl one-linercall in yourthe user crontab to rsync the folder in question to the target on a periodic basis, and because rsync doesn't do much when the folders are in syncactually IN SYNC, you shouldn't notice the periodic folder comparisons. Of course, if that sounds like too much processing, the rsync could be wrapped with a Perl script that simply maintains a touched date stamp file: only perform the rsync if the source folder has a newer date than the touched flag file, then update the touched flag file if the folder was rsync'd.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check every minute with the following crontab entry:

# run sync every minute:
* * * * * /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

If you cannot edit your crontab with:

$ crontab -e

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.all does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.

One quick and dirty way to do this would be to put a simple Perl one-liner in your crontab to rsync the folder in question to the target on a periodic basis, and because rsync doesn't do much when the folders are in sync, you shouldn't notice the periodic folder comparisons. Of course, if that sounds like too much processing, the rsync could be wrapped with a Perl script that simply maintains a touched date stamp file: only perform the rsync if the source folder has a newer date than the touched flag file, then update the touched flag file if the folder was rsync'd.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check every minute with the following crontab entry:

# run sync every minute:
* * * * * /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

If you cannot edit your crontab with:

$ crontab -e

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.all does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.

One quick and dirty way to do this would be to put a call in the user crontab to rsync the folder in question to the target on a periodic basis, and because rsync doesn't do much when the folders are actually IN SYNC, you shouldn't notice the periodic folder comparisons. Of course, if that sounds like too much processing, the rsync could be wrapped with a Perl script that simply maintains a touched date stamp file: only perform the rsync if the source folder has a newer date than the touched flag file, then update the touched flag file if the folder was rsync'd.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check every minute with the following crontab entry:

# run sync every minute:
* * * * * /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

If you cannot edit your crontab with:

$ crontab -e

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.all does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.

1
source | link

One quick and dirty way to do this would be to put a simple Perl one-liner in your crontab to rsync the folder in question to the target on a periodic basis, and because rsync doesn't do much when the folders are in sync, you shouldn't notice the periodic folder comparisons. Of course, if that sounds like too much processing, the rsync could be wrapped with a Perl script that simply maintains a touched date stamp file: only perform the rsync if the source folder has a newer date than the touched flag file, then update the touched flag file if the folder was rsync'd.

An entry for the crontab that will perform the first "quick and dirty" case on an hourly basis is:

# run sync every hour:
@hourly /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

A more aggressive polling loop would check every minute with the following crontab entry:

# run sync every minute:
* * * * * /usr/bin/rsync -av $HOME/source_path $HOME/target/path 1>> $HOME/.my_sync.log 2>&1

If you cannot edit your crontab with:

$ crontab -e

Then you'll have to give yourself permission to have a crontab. See the man page for crontab. In OSX, this is what needs to be done - the change is slightly different on linux systems: In a nutshell, make sure your user id is in /usr/lib/cron/cron.allow or that /usr/lib/cron/cron.all does not exist. Also, make sure your user id is not in /usr/lib/cron/cron.deny.

That should do it for the quick and dirty case. Check your ~/.my_sync.log file for execution statuses - this file will grow without bounds over time, so once your comfortable with how it works, change ">>" to ">" to at least log the most recent rsync status. Also, note that editing your crontab will use the editor specified by your EDITOR environment variable, so if vi isn't to your liking, change the EDITOR environment variable to /usr/bin/pico, /usr/bin/nano, or whatever, but make sure that the editor you chose edits the file in place (vi, ex, pico, and nano do), and does not unlink it, or the crontab edit will fail.