PDA

View Full Version : Cron Jobs


desertwind
04-10-2005, 01:08 AM
While trying to add cron jobs, it was ok with usual tasks. But when tried to add some programs with gui like rhythmbox and bittorrent i get some errors.

Error 1: rhythmbox
From root@localhost.localdomain Tue Oct 4 01:05:02 2005
Date: Tue, 4 Oct 2005 01:05:02 +0530
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <root@localhost> rhythmbox
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>

(rhythmbox:9435): Gtk-WARNING **: cannot open display:

Error 2: bittorrent
From root@localhost.localdomain Tue Oct 4 01:06:03 2005
Date: Tue, 4 Oct 2005 01:06:03 +0530
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <root@localhost> bittorrent
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>

Traceback (most recent call last):
File "/usr/bin/bittorrent", line 32, in ?
import gtk
File "/usr/lib/python2.4/site-packages/PIL/__init__.py", line 37, in ?

RuntimeError: could not open display

Any clues ?

firewall
04-10-2005, 10:32 PM
Cron is not really designed to run GUI applications.

:-)

sba
05-10-2005, 12:55 AM
firewall is correct. cron will most probably run GUI apps. btw i hv my doubts with this thing

X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
looks like you created cron job as root and when the GUI app is launched it is not being able to connect to X server. try and create the cron job as the user who is currently logged into X. you can use crontab to do it. not very sure whether it will work but a long shot.

desertwind
05-10-2005, 02:05 AM
i've created the cron job as root
logged in as root
and trying to run the app as root.

Is that the real problem ?

sba
05-10-2005, 02:21 AM
then it shdn't be a problem...
try to do all this as a normal user anyways and pls stop working as root.

GNUrag
05-10-2005, 11:32 AM
Its actually possible to run GUI application from cron.

1) The user who is running X should allow X authentication from all users by giving:
$ xhost +
2) The cron script should know on which X display to draw the application by:
$ export DISPLAY=:0.0

Now this will work for GUI applications started from all users.