I'm hooking a Python script up to run with cron (on Ubuntu 12.04), but authentication is not working.
The cron script accesses a couple services, and has to provide credentials. Storing those credentials with keyring
is easy as can be, except that when the cron job actually runs, the credentials can't be retrieved. The script fails out every time.
As nearly as I can tell, this has something to do with the environment cron runs in. I tracked down a set of posts which suggest that the key is having the script export DBUS_SESSION_BUS_ADDRESS
. All well and good, I can get that address and, export it, and source it from Python fairly easily. But it simply generates a new error: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
. Setting DISPLAY=:0
has no effect.
So, has anybody figured out how to unlock gnome-keyring
from Python running on a Cron job on Ubuntu 12.04?
A few years late here. But for those who encounter the same problem, I just found a solution in Come and Tech it. Basically one need to add the following code at the beginning of the python script
and then the keyring can be accessed correctly. The value of 'USERID' can be obtained by the 'id' command in shell.