Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to keep your devices in sync Apps
One problem with iSync is there is no way to schedule your Bluetooth phone's synchronization. As far as I remember, former versions of iSync did this, but it is no longer possible -- only .Mac synchronization can be scheduled. The only solution I found, since I saw no way to launch a clean background daemon, is to trigger an AppleScript every two hours, for example.

First of all, the AppleScript. I placed it in the Library/Application Support/iSync directory, and named it SyncNow.scpt:
tell application "Finder"
  set iSyncRunning to ¬
   (number of items in (processes whose name is "iSync") 
   is greater than 0)
  tell application "iSync" to synchronize
  tell application "iSync"
    repeat while (syncing is true)
    end repeat
    if iSyncRunning is not true then
      quit
    end if
  end tell
end tell
Then add this entry to your crontab (edit in Terminal with crontab -e):
0 */2 * * * osascript Library/Application\ Support/iSync/SyncNow.scpt
This will sync every two hours; type :x to quit the text editor, and you are done.
    •    
  • Currently 3.20 / 5
  You rated: 4 / 5 (5 votes cast)
 
[19,608 views]  

An AppleScript to keep your devices in sync | 9 comments | Create New Account
Click here to return to the 'An AppleScript to keep your devices in sync' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to keep your devices in sync
Authored by: frankhartman on Mar 01, '06 02:47:27PM

You can also add a recurring event in iCal that runs the applescript; i find that syncing once a day is quite enough and won't drain your cell's battery...



[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: jacobolus on Mar 01, '06 05:43:56PM

launchd is a better mechanism than either cron or ical for these sorts of things. Download the free Lingon program to make a new launchd item:

http://lingon.sourceforge.net/



[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: encro on Mar 06, '06 07:13:09AM

I second this, launchd is a great way of setting up something to trigger at a designated time. I have a iSync script that gets fired at 8am every monday which is accurate enough for my needs plus I can manually trigger an update during the week if some extensive changes are required.

Lingon is fantastic! :)



[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: loren_ryter on Mar 02, '06 11:13:54PM
This is a very nice idea -- I always forget to sync my phone. I wish there were a way to attach this script or similar to the .Mac sync instead so they all sync at the same time -- or to a Palm sync for that matter. I find it annoying that all the syncs in Tiger are now separate. You could clean up the script a bit -- too many unnecessary tell blocks and it's much better not to tie up the Finder to get processes. Use system events instead. Also the repeat loop will eat CPU unnecessarily. Stick a delay in there. ie,

tell application "System Events" to set iSyncRunning to ¬
	(number of items in (processes whose name is "iSync") is greater than 0)
tell application "iSync"
	synchronize
	repeat while (syncing is true)
		delay 5
	end repeat
	if iSyncRunning is not true then quit
end tell
Also you can use a cron job to set other times other than two hours. Remember there is a nice GUI called Cronnix for Cron. You might also want to put the script in: ~/Library/Scripts/ instead of in Application Support, so you can run it manually from the script menu too. I don't know anything about launchd -- why would it be better than cron which is built in to OS X?

[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: christernl on Mar 03, '06 08:49:56AM

since 10.4 (correct me if Im wrong), Apple use launcd instead of cron thats why



[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: beauh on Mar 08, '06 09:41:54AM

cron is still there in 10.4, it's activated by launchd (com.vix.cron)

Seeing that cron is quite a bit easier to manage than launchd (by hand at least), there's no reason that cron isn't perfectly appropriate.

- b-



[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: sly_dog_jonah on Apr 23, '06 03:13:29AM
Here's my tweak of the above script, which keeps iSync open if there have been any errors in the sync process (e.g. Bluetooth dongle missing, phone out of range). The beauty of running from iCal is that if the computer is off or asleep at the time, the script will run upon wakeup. I'm not sure if the other automated running options above would work on wakeup, but iCal certainly does.

tell application "System Events" to set iSyncRunning to ¬
	(number of items in (processes whose name is "iSync") is greater than 0)
tell application "iSync"
	synchronize
	repeat while (syncing is true)
		delay 5
	end repeat
	if (iSyncRunning is not true and sync status is 2) then quit
end tell


[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: sky33940 on Feb 18, '07 07:04:08AM
Thanks. Works perfectly. Any idea on how to make a recurring event of less than one day in iCal? Jean

[ Reply to This | # ]
An AppleScript to keep your devices in sync
Authored by: schneecrash on Jan 19, '07 09:08:35AM

this script works perfectly. thanks!

what would i add to the script to get iSync to QUIT after a successful sync?

adding an "end run" results in an error:

Library/Scripts/iSync.scpt:393:400: execution error: end of ¬Â´script¬Âª doesn't understand the run message. (-1708)
thanks!

[ Reply to This | # ]