Help getting VNC to autostart

2 1557
I have installed tightvncserver, and though it runs just fine after I manually start it. I cannot get it to autostart.
I have followed and tried over 5 different google searches on how one might do this but none of them worked.
Might anyone have an idea how to get tightvncserver to autostart ?

Edited by sghazagh at May 29, 2016 21:28

You will need root privileges for any the following. To get root, open a terminal and run the command

  1. sudo su
Copy the Code

and the command prompt will change to '#' indicating that the terminal session has root privileges.

Alternative #1. Add an initscript.

Create a new script in /etc/init.d/myscript.

  1. vi /etc/init.d/myscript
Copy the Code

(Obviously it doesn't have to be called "myscript".) In this script, do whatever you want to do. Perhaps just run the command runs the VNC server.

  1. #!/bin/sh
  2. /path/to/my/
Copy the Code

Make it executable.

  1. chmod ugo+x /etc/init.d/myscript
Copy the Code

Configure the init system to run this script at startup.

  1. update-rc.d myscript defaults
Copy the Code

Alternative #2. Add commands to /etc/rc.local

  1. vi /etc/rc.local
Copy the Code

with content like the following.

  1. # This script is executed at the end of each multiuser runlevel
  2. /path/to/my/ || exit 1   # Added by me
  3. exit 0
Copy the Code

Alternative #3. Add an Upstart job.

Create /etc/init/myjob.conf

  1. vi /etc/init/myjob.conf
Copy the Code

with content like the following

  1. description     "my job"
  2. start on startup
  3. task
  4. exec /path/to/my/
Copy the Code

Alternative #4. Add as a systemd Service.

First of all, your OS should support systemd. Not sure what OS do you use, but if you use any of Ubuntu OSs after 15.04 , systemd is supported.
You can use my latest Lubuntu 16.04 LTS image if you like. Post is HERE.

You need first to create a UNIT file. Something like this:
On Ubuntu OS, unit files are located within the R/W filesystem at /etc/systemd/system. Let's create a simple unit named hello.service:

  1. [Unit]
  2. Description=MyApp
  3. After=aaa.service
  4. Requires=aaa.service

  5. [Service]
  6. TimeoutStartSec=0
  7. ExecStartPre=-/usr/bin/<someapp>kill <otherapp>
  8. ExecStartPre=-/usr/bin/<someapp> rm <otherapp>
  9. ExecStartPre=/usr/bin/<someapp> pull <otherapp>
  10. ExecStart=/bin/sh -c "while true; do echo Hello World; sleep 1; done"

  11. [Install]
Copy the Code
The Description shows up in the systemd log and a few other places. Write something that will help you understand exactly what this does later on.

After=aaa.service and Requires=aaa.service means this unit will only start after aaa.service is active. You can define as many of these as you want.

ExecStart= allows you to specify any command that you'd like to run when this unit is started. The pid assigned to this process is what systemd will monitor to determine whether the process has crashed or not.
  1. Note:You may not need any of above (After, Requires,ExecstartPre) , I just mentioned them for explanation...
Copy the Code
WantedBy= is the target that this unit is a part of.

To start a new unit, we need to tell systemd to create the symlink and then start the service:

  1. # systemctl enable hello.service
  2. # systemctl start hello.service
Copy the Code

In next boot, Service will be started and your script or command to enable the VNCServer will be executed automatically.

Hope it helps,

ELAR-Systems   (Visit our Facebook Page)   (Join our Google+ page)

I have downloaded it 2 months ago for my new laptop. The only issue with the software is that I paid for this software after reading all the features in the updated version in best assignment writing service  , after the trial version of 30 days, the payment is done but it is not allowing me to access it for my laptop so please consider my issue and solve it as early as possible.

You have to log in before you can reply Login | Sign Up

Points Rules