Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

unixperience

macrumors regular
Original poster
Jul 21, 2010
235
5
Hello, not exactly programming, but scripting; I wrote an bash script that syncs two folders, and set it as a folder action. here is a sample:

echo "syncing from server to local"
rsync -avru -progress --delete LOCAL_SOURCE TARGET_SERVER
echo "operation complete"

I have it associated with a folder, and it syncs all subfolders already, since i told rsync to sync recursively, however can i get this to run anytime there is a change in any subfolder of LOCAL_SOURCE ????

I could of course associate the folder action with every single subfolder, but there are hundreds. and new folders are added and deleted everyday, I wouldn't want to associate the script every time I make a new folder. anyway to get around this?

i'm fairly proficient with programming so I can use scripts or automator, just about anything, so ALL ideas are welcome
 

sero

macrumors member
Aug 28, 2008
91
14
Wirelessly posted (Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3)

So use launchd
 

MorphingDragon

macrumors 603
Mar 27, 2009
5,160
6
The World Inbetween
Hello, not exactly programming, but scripting; I wrote an bash script that syncs two folders, and set it as a folder action. here is a sample:

echo "syncing from server to local"
rsync -avru -progress --delete LOCAL_SOURCE TARGET_SERVER
echo "operation complete"

I have it associated with a folder, and it syncs all subfolders already, since i told rsync to sync recursively, however can i get this to run anytime there is a change in any subfolder of LOCAL_SOURCE ????

I could of course associate the folder action with every single subfolder, but there are hundreds. and new folders are added and deleted everyday, I wouldn't want to associate the script every time I make a new folder. anyway to get around this?

i'm fairly proficient with programming so I can use scripts or automator, just about anything, so ALL ideas are welcome

Try this:
http://code.google.com/p/lsyncd/
 

unixperience

macrumors regular
Original poster
Jul 21, 2010
235
5
Cron job to run the script every 5 minutes?

Yeah I thought that would be one way to do it... but I wanted instant updates whenever a change is applied, but I suppose using cron is probably better for the harddrive, so its not updating with every autosave. cron is looking like the best answer, for me anyway


thanks everyone for your help. I may not understand launchd properly, but it looks like it only runs at boot? do you schedule tasks similar to cron?


but thanks again to everyone :)
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
I may not understand launchd properly, but it looks like it only runs at boot? do you schedule tasks similar to cron?

It does schedule things like cron, but it does more, like supervising background processes, running boot scripts and so on. Unlike cron it can act upon events, like changes in files and folders, mounting of volumes and so on which is what the link I provided shows. But I agree that cron may be better in this case, but it depends on your requirements, it's simpler.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.