I am fairly new to Linux and using Ubuntu. I am trying to set-up a task alert everyday at a fixed time. I am using the "Scheduled tasks" software tool(I have installed this) for the same. This software requires that we give it a command to be run at a specified time of the day so it gives the desired output at the scheduled time.

I am writing an alert message inside a file named alert.txt and trying to launch this using gedit to display the alert message. I am using the following command

gedit /home/xzyabc/path/alert.txt

This command seems to work fine in terminal but fails to launch the gedit editor when it runs through the scheduled software. Can you help me fix this?

Thank you!!

  • It looks like you would be better off using zenity, but if you must use gedit, perhaps you need to use the full path, like /usr/bin/gedit /home/xzyabc/path/alert.txt.
    – Jos
    Aug 6, 2015 at 9:17
  • How is this scheduled? Because it may happen that the gedit action is being performed by another user, the user of the binary running the scheduler.
    – fedorqui
    Aug 6, 2015 at 9:20
  • @Jos, I am able to launch the editor using the same command on the terminal. How does the command without giving the full path of gedit work in terminal?
    – Sushant
    Aug 6, 2015 at 9:29
  • The environment that cron runs things in is a lot more limited than that you get when you open a terminal. It's often unwise to rely on $PATH being set to something sensible, especially when the path is so easy to specify.
    – Oli
    Aug 6, 2015 at 9:30

1 Answer 1


What are you using to schedule? If it's cron-based, it likely doesn't have a DISPLAY variable set, so it doesn't know where to render the window. I'd recommend changing the command to include the DISPLAY, assuming it's the default :0:

DISPLAY=:0 /usr/bin/gedit /path/to/file

To debug cron issues, you can emulate a cron-like environment in a terminal:

env -i /bin/bash --noprofile --norc

That'll dump you on a horribly restricted terminal, but it'll give you some idea what cron is working from. If you get your command working from there, it should work in cron.

  • I am using a software called scheduled tasks apps.ubuntu.com/cat/applications/gnome-schedule
    – Sushant
    Aug 6, 2015 at 9:26
  • Yeah, it's using cron, the above should work.
    – Oli
    Aug 6, 2015 at 9:29
  • I tried to run with the modifications suggested by you. It is showing some output, but the editor momentarily opens in a flash and goes...
    – Sushant
    Aug 6, 2015 at 9:36
  • I've added a section on debugging. It isn't easy to accurately emulate the environment but you can get close enough to get useful error messages back.
    – Oli
    Aug 6, 2015 at 9:45
  • 1
    @GRK: As you're a reputation 6 user: If this answer helped you, don't forget to click the grey at the left of this text, which means Yes, this answer is valid! ;-)
    – Fabby
    Sep 7, 2015 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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