Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using a BASH script, I need to launch a GUI application at boot in such a way that I can later connect via RDP or VNC and see the application running. For example, the script will run at boot and launch a given GUI-based analysis application. At any time later, I need to RDP/VNC in to see the application's progress and interact with it.

So far, I am using LXDE on Ubuntu Server 12.04.1 running on EC2.

share|improve this question

Two different approaches depending on whether that GUI-based application needs to be running since bootup or not:

  • the application in question is not only a frontend, but performs the actual work. In this case, you need an upstart script to launch the app, and a VNC or RDP server also configured to be run from the bootup scripts. This is not a secure approach.
  • the application is only a web frontend. In this case, you can do better by launching the applicationn on demand through an SSH tunnel, provided you enable X11Forwarding in your ssh config. Then it is as simple as ssh -X user@host 'gui-app'
share|improve this answer
I need to be able to run arbitrary applications, most of which are not web frontends. Examples are chrome, gimp, etc. I have an upstart script that I can use to launch them, but they don't run successfully before the user logs in because they can't open an X session for display. The upstart script needs to somehow launch an X session, launch the application inside it, then disconnect so the user can reattach to the session using RDP or VNC. I've been using xrdp, which works other than the mentioned issue, but I could switch to VNC if that would somehow be better. – Shaun Apr 10 '13 at 13:54

Ahh, the couple ways we can do this. You actually had 2 questions from what I see.

Question 1: How do I launch a bash script at boot?
Answer 1a: As root, make an upstart launch script , see upstart docs.
Answer 1b: Option 2 as user with no root access. Create a cron job that runs every 5 minutes to check to make sure bash script isn't already running and if it isn't, start said process.

Question 2: How do I launch the application in VNC/RDP?
Answer 2: RDP is not well supported. VNC is not very secure, but if you insist. Start vnc server once by hand, set up password. This will also create the .vnc directory for the configuration. Now edit the .vnc/xstartup and add the startup of the program/bash script.

Going back to Answer 1a+b, you should then add the startup of vncserver as your startup and not the script itself. The starting of vncserver will then start the application once.

Example for cron:
*/5 * * * * pgrep -u $USER vncserver > /dev/null || vncserver -geometry 1024x768

Mileage of above script varies. Feel free to add a bit more verbosity.

share|improve this answer

upstart will work, and the only other thing for remote GUI access would be xRDP. Here's a link on installing and configuring it:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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