Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to run a program that pops up a graphical notice to me. As a simple example, I have my cron settings as

@hourly xlogo

and if I launch xlogo from an interactive command, it works fine. However, when run by cron, the xlogo window never launches. How can I get cron to let xlogo launch a window, or is it just fundamentally not designed to do that?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

It is totally possible to do this with crontab.

You need to tell the script which screen you want xlogo to run on.

Try changing the line to this:

@hourly /usr/bin/env DISPLAY=:0.0 /usr/bin/xlogo

to tell crontab what display you want it to use. Depending on the program you might need to add in more enviornment variables as well.

share|improve this answer
    
it worked! thanks –  Stephen Aug 22 '12 at 22:05

You need to tell it which display to use with the export command. I also would recommend always using the full path to a file with cron. It will save you a lot of headaches, as cron runs in a limited environment, so it doesn't always have the same $PATH variable as your terminal. This means it doesn't always know where programs are located.

At any rate, your cron job would look something like this:

@hourly export DISPLAY=:0.0 && /usr/bin/xlogo
share|improve this answer
    
I tried this and also the version suggested by Alex L. Both of them work fine. Thanks very much! –  Stephen Aug 22 '12 at 22:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.