I'm learning about Linux scheduling commands including at, cron, sleep etc. I'm trying to launch gedit after x minutes via the at command. This is what I have:

kedar@i5 ~ $ at now + 1 minute
at now + 1 minute
warning: commands will be executed using /bin/sh
at> ./s.sh
at> <EOT>
job 18 at Fri Aug 15 13:21:00 2014

The contents of s.sh (-rwxr--r--):

#set $DISPLAY=:0
echo "Created on" `date` >t.txt
gedit #(also tried /usr/bin/gedit and `gedit` and systen(/usr/bin/gedit))

After 1 minute, t.txt is created with the expected contents. However, gedit is not launched. For that matter, none of my programs(firefox,xcalc,xfce4-terminal etc) can be launched this way via at.

Strange thing is, when I run ./s.sh in bash, gedit opens up fine.

Also I tried running at (from a file - if this is at all correct) as:

kedar@i5 ~ $ at now + 1 minute -f ./s.sh

I guess there's something wrong with the way I'm using at with the shell script. Also can't I use at without a shell script? Thanks.


You need to set the display variable, but this is done as:

export DISPLAY=":0"

and then

at now + 1 minute -f test.sh

works for me on Ubuntu 14.04.1 LTS

  • Running xhost+ outputs: access control disabled, clients can connect from any host. Tried uncommenting the display var, still no go. – black_stallion Aug 15 '14 at 8:18
  • Totally! That worked! export DISPLAY=":0" is apparently not the same as set $DISPLAY=:0. I have a lot to learn.. Thanks a bunch! – black_stallion Aug 15 '14 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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