It used to be fairly easy to run SyncEvolution as a cron job. Starting with GNOME 2.24 (as included in Ubuntu 8.10 Intrepid) it became a bit more complicated. The automatic initialization of D-Bus (required for access to gconf and thus the list of available Evolution databases) now depends on an X session, which is not available in cron.
The result is the following error:
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://www.gnome.org/projects/gconf/ for information. (Details - 1: Not running within active session)
A solution for Python is discussed on Stack Overflow. Here’s how the problem can be solved for SyncEvolution. In your crontab, use:
54 9 * * * env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; syncevolution'
This starts a D-Bus session (dbus-launch), runs syncevolution, then kills the D-Bus daemon (via the process ID set by dbus-launch) once syncevolution completes. It does that every day at 9:54. If you change that, then don’t run it too often, because that can consume a lot of resources on the server.