GNOME Bugzilla – Bug 639776
gnucash --add-price-quotes fails when run from cron (or ssh w/o X) with GConf Error
Last modified: 2018-06-29 22:52:12 UTC
--add-price-quotes works from command line, but not from cron Subject: Cron <jeff@fx> /usr/local/bin/gnucash --add-price-quotes /path/to/file.gnucash (failed) Content-Type: text/plain; charset=ANSI_X3.4-1968 X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/home/jeff> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=jeff> GConf Error: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Not running within active session) Found Finance::Quote version 1.17 Failed to load key /apps/gnucash/general/retain_days: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Not running within active session)Failed to load key /apps/gnucash/general/file_compression: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Not running within active session)Failed to load key /apps/gnucash/general/retain_type: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Not running within active session)Failed to save key /apps/gnucash/general/retain_type: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information. (Details - 1: Not running within active session)
c.f. http://lists.gnucash.org/pipermail/gnucash-user/2010-September/036373.html
Ubuntu 10.10 jeff@fx:~$ which gconftool-2 /usr/bin/gconftool-2 jeff@fx:~$ which dbus-launch /usr/bin/dbus-launch Potentially related: http://www.estamos.de/blog/2009/05/08/running-syncevolution-as-cron-job/ 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.
env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; /usr/local/bin/gnucash --add-price-quotes /path/to/file.gnucash' runs successfully. Dropping priority with work-around. Suggest considering kicking off dbus when not in an X session. Also fails when ssh-ed in without an X session established.
http://www.gnucash.org/docs/v2.2/C/gnucash-help/acct-create.html#Online-price-setup probably should be modified to reflect this
http://wiki.gnucash.org/wiki/Online_quote updated
Err... and this bugreport is just the reminder for gnucash that this won't work as long as gconf requires a running X session?
At the very least, the documentation should be updated. In my opinion, as "--add-price-quotes" seems intended to be run as a scheduled, non-interactive process, either the dependencies for having gconf running for that action should be removed, or a "local" gconf session should be initiated if one is not detected.
Jeff, docs/v2.2 is somewhat outdated, file the enhancement against http://svn.gnucash.org/docs/help/acct-create.html#Online-price-setup
(In reply to comment #7) > At the very least, the documentation should be updated. Agreed, so I will assign it to the documentation component. > In my opinion, as "--add-price-quotes" seems intended to be run as a scheduled, > non-interactive process, either the dependencies for having gconf running for > that action should be removed, or a "local" gconf session should be initiated if > one is not detected. Not always, see e.g. 628734: Get Quotes at Startup Option https://bugzilla.gnome.org/show_bug.cgi?id=628734
I'm going to update the help documentation for this. I can see a few places with obviously out of date info that I'll also fix. Can some-one please tell me if OSX has crontab functionality or should I make it clear this only applies to Linux?
I see from googling that OSX does have cron functionality. Can a Mac user please advise if setting up a cron job to do: env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; /path/to/gnucash --add-price-quotes /path/to/file.gnucash' works?
John Ralls says: No, it doesn't work like Linux because dbus isn't available in OS X, but it's not necessary for the cron job to worry about it. Just run /path/to/Gnucash.app/Contents/MacOS/Gnucash —add-price-quotes /path/to/file.gnucash and dbus will take care of itself. Or not, it's not used on Gnucash 2.6. Regards, John Ralls I tested in Linux Ubuntu 14.04 GnucCash 2.6.1: Using dbus-launch works Without dbus-launch, fails Johns comment 'it's not used on Gnucash 2.6' must only apply to Mac OS X, not Linux. Thanks John.
Created attachment 319659 [details] [review] Update instructions for updating quote prices by cron
Comment on attachment 319659 [details] [review] Update instructions for updating quote prices by cron GnuCash under Linux needs no running X session, but dbus to communicate with {d|g}conf. And dbus is usually started by the desktop manager. But it can get started by dbus-launch, too.
Created attachment 319723 [details] [review] Update instructions for updating quote prices by cron This is a replacement patch
Hi Frank, Thanks from clarifying that. I have attached a replacement patch.
Review of attachment 319723 [details] [review]: commit 506fc58
This problem has been fixed in our software repository. The fix will go into the next software release. Once that release is available, you may want to check for a software upgrade provided by your Linux distribution.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=639776. Please update any external references or bookmarks.