Page 4 of 4 FirstFirst ... 234
Results 31 to 33 of 33

Thread: crontab: How to run GUI programs with cron

  1. #31
    Join Date
    Oct 2009
    Location
    China
    Beans
    6

    Re: crontab: How to run GUI programs with cron

    Code:
    export DISPLAY=:0.0 && /usr/bin/gnome-terminal
    There is something different between GUI app started from cron and normal ways. In terminal, env variables for example are not the same. Settings set in .bashrc do not work.
    What's different between cron and normal ways. I'm curious about it.

  2. #32
    Join Date
    Apr 2005
    Location
    Sintra, Portugal
    Beans
    835

    Re: crontab: How to run GUI programs with cron

    Quote Originally Posted by rob2468 View Post
    Code:
    export DISPLAY=:0.0 && /usr/bin/gnome-terminal
    There is something different between GUI app started from cron and normal ways. In terminal, env variables for example are not the same. Settings set in .bashrc do not work.
    What's different between cron and normal ways. I'm curious about it.
    If unspecified, they're started as root (or as the cron user). You have to specify the user for it. This will set the proper environment variables.

    Example:
    11 * * * * your_user_here /path/to/command
    <timing> <user> <command>

  3. #33
    Join Date
    Feb 2008
    Beans
    19

    Re: crontab: How to run GUI programs with cron

    One thing that a lot of people probably don't realize is that you can set environment variables for a specific command by just putting them in front of the line. So, for the example of setting the DISPLAY variable in this thread, you can do this in cron:

    Code:
    0 11 * * *  DISPLAY=:0 /usr/bin/gnome-terminal
    Just make sure you only put spaces in between the variable setting and the command. It is actually more useful in other cases where you only want to change an environment variable for a specific command.

Page 4 of 4 FirstFirst ... 234

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •