Open a terminal from a Crontab

10,548

Solution 1

You can't, safely. cron jobs run independent of the desktop session where X is running, therefore you can't do this without causing security violations.

Solution 2

* * * * * export DISPLAY=:0 && /usr/bin/gnome-terminal

Though this is not really a robust solution since there's no guarantees that X server will be on :0.

Share:
10,548
userend
Author by

userend

Updated on September 18, 2022

Comments

  • userend
    userend over 1 year

    How do I get a gnome-terminal window to open from a crontab?

    I have tried this:

        * * * * * /usr/bin/gnome-terminal 
    
        * * * * * source /home/user_name/.bashrc ; /usr/bin/gnome-terminal
    
        * * * * * source /home/user_name/.profile ; /usr/bin/gnome-terminal
    
        * * * * * source /home/user_name/.bashrc ; /home/user_name/bin/opengnometerminal.sh
    

    None of these seem to work.

    • Admin
      Admin over 12 years
      Haven't used X in awhile but you probably need DISPLAY set in your environment.
    • hafichuk
      hafichuk over 12 years
      Why are you trying to do this?
    • userend
      userend over 12 years
      I want to send myself a message at a certain time. I will find another way.
  • Ignacio Vazquez-Abrams
    Ignacio Vazquez-Abrams over 12 years
    There's also no guarantees that the user crond runs as will have the X auth cookie.
  • userend
    userend over 12 years
    This is what I got when I tried that on my system: <code> Failed to parse arguments: Cannot open display: </code> I think I will try Python-notify.
  • userend
    userend over 12 years
    This is what I got when I tried that on my system: [code] Failed to parse arguments: Cannot open display: [/code] I think I will try Python-notify.
  • userend
    userend over 12 years
    Thanks for your help I will try Python-notify to accomplish this task.
  • Scott - Слава Україні
    Scott - Слава Україні about 5 years
    What is /home/user/show-my-script-in-window-terminal.sh?