DIGIT-ARC read-only archive · snapshot: July 23, 2026

Cron Jobs

6 posts · originally from https://geek.digit.in/community/threads/cron-jobs.16433/

desertwind
desertwind Original post #1
Oct 4, 2005 at 1: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
Code:
From [email]root@localhost.loca[/email]ldomain  Tue Oct  4 01:05:02 2005
Date: Tue, 4 Oct 2005 01:05:02 +0530
From: [email]root@localhost.loca[/email]ldomain (Cron Daemon)
To: [email]root@localhost.loca[/email]ldomain
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
Code:
From [email]root@localhost.loca[/email]ldomain  Tue Oct  4 01:06:03 2005
Date: Tue, 4 Oct 2005 01:06:03 +0530
From: [email]root@localhost.loca[/email]ldomain (Cron Daemon)
To: [email]root@localhost.loca[/email]ldomain
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
Oct 4, 2005 at 10:32 PM
Cron is not really designed to run GUI applications.

:)
S
sba #3
Oct 5, 2005 at 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
Oct 5, 2005 at 2: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 ?
S
sba #5
Oct 5, 2005 at 2: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
GNUrag #6
Oct 5, 2005 at 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.