Cronjob / Virtual terminal problem

Nathan Samson nathansamson+fedora at gmail.com
Tue Jun 14 10:53:19 UTC 2011


Hi,

I have a simple python program that takes backups. It calls rsnapshot, but
the python program does 2 things
A) It checks if mij external drive is mounted, if not it uses
gio.VolumeMonitor to detect mounting, and if the correct one is mounted it
proceeds
B) uses pynotify to give notifications (External drive is not mounted,
taking backup, ...).

This works perfectly when I'm logged in (in X), and starting the program in
gnome-terminal.

When I try this in a cronjob (using DISPLAY=:0, which is not foolproof but
works for me in 99.99999% of the cases), and setting the correct dbus
session vars with
"
for file in `ls -1tr ~/.dbus/session-bus/`; do
    source ~/.dbus/session-bus/"$file"
done

"

this does NOT work. I see the notifications (dbus seems working), but the
mount-added signal from VolumeMonitor is never received.
Also when I try this in a virtual-terminal (ctrl-alf-f2), it doesn't work
(same problem, notifications are working, mount-added signal is noet).

When I used the exact same script in Ubuntu (11.04) it worked perfectly.


So: what is the difference between a virtual-terminal and cronjob on the one
side, and X (gnome-terminal) on the other side when the correct environment
variables are set?
And what is the difference between Ubuntu and Fedora?

I personally could only think of one thing and that is selinux, but I
disabled that with "setenforce 0", and that didn't help.


So Does anyone have an idea what the problem is, and how I can solve it?
(One idea could be to not use VolumeMonitor, but a while loop that checks
availability, but that does seem to be a nasty hack).

Greetings,
Nathan

--
To understand recursion, you must first understand recursion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20110614/de0b1428/attachment.html 


More information about the users mailing list