Re: Unison + launchd?
Eberhard W Lisse <[email protected]> Sun, 16 Feb 2025 13:44:03 +0200
| Newsgroups | gmane.network.unison.general |
|---|---|
| Message-ID | <65442964-387a-436f-9451-d821071cbc49@Spark> |
On the Mac crontab does not work well for many things since Monterey, because of Security and Privacy changes (which Apple doesn’t tell you about, so you find out when the scripts fail). So you need to write launchd plists which fire up these shell scripts. Not too much of a drama, there are Apps like Lingon (X) which make this very easy. Never mind that I doubt osascript popups will work in the background I think running Unison without adult is not a good idea as you may, inadvertently, delete files. On my two desktops and two laptops I run Time Machine to a Time Capsule in the WLAN which all see if and when they are turned on at home, and to an external hard disk each, which for the Laptops I connect if/before I leave the house and put in the backpack. That takes care of not losing files inadvertently. For synchronization I use Unison additionally. One of my desktops is the ‘hub’ to which all others connect via unison. I have a bash script that figures out on which machine it is running and then runs unison to the ‘hub’ and via ssh on the ‘hub’ to the second desktop, or if on the ‘hub’ only to the second Desktop (and the other way round) and I see what is being transferred, deleted or conflicted. If I am not sure what’s what, I run Unison with the GUI and manually select, if necessary, but if I made some changes on one system only, this works brilliantly, even while traveling. In general I exclude ~/Library and ~/Pictures as I run Monterey on one and Sequoia on the others, as I sync the images to the iCloud anyway and have them on the Time Machines. I am also playing with Ubuntu on a tiny Pantera Pico, which has Unison preinstalled, and works well. greetings, el -- Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist (retired) [email protected] / * | Telephone: +264 81 124 6733 (cell) PO Box 8421 Bachbrecht \ / If this email is signed with GPG/PGP 10007, Namibia ;____/ Sect 20 of Act No. 4 of 2019 may apply On Feb 16, 2025 at 05:24 +0200, 'Jason J. Corso' via unison-users <[email protected]>, wrote: > > Hi Benjamin, > > I dug up this script that I was using for a while. I had this running hourly in a cronjob. The notification is macos specific. It's a simple hack, really. But, should work. > > --- > #!/bin/bash > > # Unison profile name (or specify paths directly) > UNISON_PROFILE="..." > MESSAGE="Unison Sync Completed with Changes" > > LOG_FILE="/tmp/unison_sync.log" > rm $LOG_FILE > > # Run Unison and capture output > unison "$UNISON_PROFILE" -batch -terse > "$LOG_FILE" > > # Check if the log file has any content (indicating changes or conflicts) > if [[ -s "$LOG_FILE" ]]; then > osascript -e "display notification \"$MESSAGE\" with title \"Unison Sync\"" > > logger "Unison Sync: Changes detected. Check $LOG_FILE for details." > fi > > --- > > Thanks, > Jason > On Sat, Feb 15, 2025 at 5:58 PM Benjamin Pierce <[email protected]> wrote: > > > I wonder if anyone has a recipe for periodically running Unison in the background (e.g., as a launchd service), and notifying the user (e.g., by popping up an alert) only when the sync actually transfers some files or runs into a conflict (i.e., when the output is non-empty). Bonus points if it works on MacOS. > > > > Thank you! > > > > - Benjamin > > > > > > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > > > > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].