After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 639776 - gnucash --add-price-quotes fails when run from cron (or ssh w/o X) with GConf Error
gnucash --add-price-quotes fails when run from cron (or ssh w/o X) with GConf...
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Documentation
2.4.x
Other Linux
: Normal normal
: ---
Assigned To: Andreas Köhler
Andreas Köhler
Depends on:
Blocks:
 
 
Reported: 2011-01-17 19:06 UTC by Jeff Kletsky
Modified: 2018-06-29 22:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Update instructions for updating quote prices by cron (3.97 KB, patch)
2016-01-25 07:19 UTC, Chris Good
needs-work Details | Review
Update instructions for updating quote prices by cron (4.05 KB, patch)
2016-01-26 05:02 UTC, Chris Good
committed Details | Review

Description Jeff Kletsky 2011-01-17 19:06:24 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)
Comment 2 Jeff Kletsky 2011-01-17 19:44:52 UTC
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.
Comment 3 Jeff Kletsky 2011-01-17 20:29:19 UTC
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.
Comment 4 Jeff Kletsky 2011-01-17 21:51:53 UTC
http://www.gnucash.org/docs/v2.2/C/gnucash-help/acct-create.html#Online-price-setup

probably should be modified to reflect this
Comment 5 Jeff Kletsky 2011-01-17 22:11:54 UTC
http://wiki.gnucash.org/wiki/Online_quote

updated
Comment 6 Christian Stimming 2011-01-18 08:08:22 UTC
Err... and this bugreport is just the reminder for gnucash that this won't work as long as gconf requires a running X session?
Comment 7 Jeff Kletsky 2011-01-18 17:30:13 UTC
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.
Comment 8 Frank H. Ellenberger 2011-01-18 17:53:45 UTC
Jeff, docs/v2.2 is somewhat outdated, file the enhancement against http://svn.gnucash.org/docs/help/acct-create.html#Online-price-setup
Comment 9 Frank H. Ellenberger 2013-04-04 04:31:36 UTC
(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
Comment 10 Chris Good 2016-01-21 06:41:39 UTC
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?
Comment 11 Chris Good 2016-01-22 04:37:58 UTC
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?
Comment 12 Chris Good 2016-01-25 07:17:16 UTC
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.
Comment 13 Chris Good 2016-01-25 07:19:02 UTC
Created attachment 319659 [details] [review]
Update instructions for updating quote prices by cron
Comment 14 Frank H. Ellenberger 2016-01-26 01:30:33 UTC
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.
Comment 15 Chris Good 2016-01-26 05:02:59 UTC
Created attachment 319723 [details] [review]
Update instructions for updating quote prices by cron

This is a replacement patch
Comment 16 Chris Good 2016-01-26 05:04:43 UTC
Hi Frank,

Thanks from clarifying that. I have attached a replacement patch.
Comment 17 Frank H. Ellenberger 2016-01-26 08:07:59 UTC
Review of attachment 319723 [details] [review]:

commit 506fc58
Comment 18 Frank H. Ellenberger 2016-01-26 08:12:14 UTC
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.
Comment 19 John Ralls 2018-06-29 22:52:12 UTC
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.