Schedule a Zotero Sync

Hello Everyone,

I was wondering if there was a way to automatically schedule the zotero standalone client to synchronize on a linux computer?

I'm working on creating a standalone central backup computer and my last step is coming up with a way to schedule the synchronization.

I was hoping that there would be a command-line argument I could pass to the standalone app that would trigger the sync, but so far no luck.

The brute force solution would be to start the standalone client one hour before the backup and hope it completes in time.

Any hints would be appreciated. I'm a developer so if code is the answer I can look there as well.

Thanks.

mark.
  • I don't have any easy ideas. There is obviously a javascript function in Zotero that triggers code (Dan would know the name, but also shouldn't be hard to figure out) but you need to be within mozilla to call it. Given that, my initial thought would be that the best way to is an add-on that allows you to schedule a sync.
  • From looking at the javascript quickly it looks like the functions I want are:

    Zotero.Sync.Server.sync()

    or:

    Zotero.Sync.Runner.sync({ background: true });

    But like you said the app needs to be running for that to work. Maybe the Web API is the way to go?
  • You know that with auto-sync enabled Zotero syncs automatically every hour? So if you just leave it open, you'll always have the latest changes within an hour.
  • Hi Dan, no I did not know that. I thought that auto-sync controlled whether or not zotero would synchronize when launched.

    Would there be any danger backing up the zotero folder while zotero was mid-sync?

    If not I think leaving zotero running would be a decent solution, maybe I'll write another cron job that will check to make sure that zotero is running, and if not launch it, just in case there is a reboot or a crash.

    For my purposes, I'd love to see a command line switch, or a standalone app that we could use to easily trigger a synchronization programatically.

    Thanks Dan and Adam!

    mark.
  • For anyone that cares here is the shell script that I cobbled together using trial and error, google, and stackoverflow:


    #!/bin/bash

    case "$(pidof zotero | wc -w)" in

    0) echo "Restarting Zotero"
    cmd="zotero"
    eval "${cmd}" &>/dev/null &disown
    ;;
    1) echo "Zotero already running"
    ;;
    esac


    This checks to see if zotero is running, and if not starts zotero and then exits.
Sign In or Register to comment.