Open a terminal from a Crontab

3

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.

userend

Posted 2011-10-28T03:22:08.807

Reputation: 145

Haven't used X in awhile but you probably need DISPLAY set in your environment. – None – 2011-10-28T03:25:59.067

You could use cron to touch a file somewhere and use an inotify script (which is running in your X session) to watch the file and launch a terminal when the file changes... – Mel Boyce – 2011-10-28T03:26:07.340

Why are you trying to do this? – hafichuk – 2011-10-28T03:30:15.843

I want to send myself a message at a certain time. I will find another way. – userend – 2011-10-29T22:50:38.997

Answers

2

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.

Ignacio Vazquez-Abrams

Posted 2011-10-28T03:22:08.807

Reputation: 100 516

Thanks for your help I will try Python-notify to accomplish this task. – userend – 2011-10-29T22:49:36.657

3

* * * * * 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.

hafichuk

Posted 2011-10-28T03:22:08.807

Reputation: 406

3There's also no guarantees that the user crond runs as will have the X auth cookie. – Ignacio Vazquez-Abrams – 2011-10-28T03:42:21.153

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 – 2011-10-29T22:44:29.440

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 – 2011-10-29T22:48:53.710

0

In Xubuntu add in crontab the command:

exo-open --launch TerminalEmulator /home/user/show-my-script-in-window-terminal.sh

Avansot

Posted 2011-10-28T03:22:08.807

Reputation: 1

What is /home/user/show-my-script-in-window-terminal.sh? – Scott – 2019-02-17T16:12:17.120