Hcgrant
Posts: 17
Joined: Sun Oct 14, 2012 4:51 pm

Can't get rc.local to run vncserver at boot

Wed Feb 13, 2013 4:23 pm

Hi , Im hoping someone can explain this to me ...
I want to run vncserver at boot so ive added the following to /etc/rc.local ..
----------------------------------------------------
#
# my bit to start the VNC server
#
/usr/bin/vncserver
date >> /home/pi/vnclocalran # to monitor that rc.local ran and when
#
# end of my bit
--------------------------------------------------
This will execute perfectly from the command prompt and start vncserver.
However for some reason this script wont start vncserver from a cold start (powering up) or from a restart.
I know rc.local is being executed because I can look at the timestamp in the file /home/pi/localvncran
Is there something odd about vncserver that wont let it be started this way?
I have added an "&" after the vncserver command but this doesnt help

I see that there are methods to start vncserver at boot , I havent tried them yet , but I would like to understand why my method isnt working
All suggestions gratefully received ;-)))

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: Can't get rc.local to run vncserver at boot

Wed Feb 13, 2013 4:38 pm

What user do you think will configured to run the server instance you are attempting to start?

From the command line, you're probably the pi-user, from rc.local it will be root. As things stand try running

Code: Select all

ps -lef | grep -v grep | grep vnc
which will show vnc processes running on your system (if any).

The other methods you refer to address this issue in a number of ways.

hunternet93
Posts: 336
Joined: Mon Dec 12, 2011 4:34 pm

Re: Can't get rc.local to run vncserver at boot

Wed Feb 13, 2013 4:44 pm

In Debian and Debian-based distros, you can set most services to start on boot with the command:

Code: Select all

sudo update-rc.d servicename enable
You could try that with your VNC server, I haven't tested but I'm guessing it'll work.

RobinMosedale
Posts: 44
Joined: Tue Jan 29, 2013 10:55 am

Re: Can't get rc.local to run vncserver at boot

Fri Feb 15, 2013 3:33 pm

hunternet93 wrote:In Debian and Debian-based distros, you can set most services to start on boot with the command:

Code: Select all

sudo update-rc.d servicename enable
You could try that with your VNC server, I haven't tested but I'm guessing it'll work.
I'm afraid I get error: "cannot find a LSB script for vncserver"

If sudo update.rc.d tightvncserver enable is used, then an error:-
"tightvncserver Default-Start contains no runlevels, aborting

Any ideas?

Thanks
Robin

Hcgrant
Posts: 17
Joined: Sun Oct 14, 2012 4:51 pm

Re: Can't get rc.local to run vncserver at boot

Fri Feb 15, 2013 8:33 pm

Hi DBryiant ..thanks for the reply
Ive checked for the vnc server running after boot with "ps axu" ...its not running.
I wondered if it wont run as root and tried "sudo vncserver" .. that started the vnc server and I can login.
So thats not the problem ... :-(
I'll try the method given in http://www.penguintutor.com/linux/tightvnc and see if that works, if it does I still would like to know why my method doesnt ... I thought rc.local was the place for users to start their own processes at startup


andrum99
Posts: 707
Joined: Fri Jul 20, 2012 2:41 pm

Re: Can't get rc.local to run vncserver at boot

Fri Feb 15, 2013 8:47 pm

Hcgrant wrote:Hi , Im hoping someone can explain this to me ...
I want to run vncserver at boot so ive added the following to /etc/rc.local ..
----------------------------------------------------
#
# my bit to start the VNC server
#
/usr/bin/vncserver
date >> /home/pi/vnclocalran # to monitor that rc.local ran and when
#
# end of my bit
--------------------------------------------------
This will execute perfectly from the command prompt and start vncserver.
However for some reason this script wont start vncserver from a cold start (powering up) or from a restart.
I know rc.local is being executed because I can look at the timestamp in the file /home/pi/localvncran
Is there something odd about vncserver that wont let it be started this way?
I have added an "&" after the vncserver command but this doesnt help

I see that there are methods to start vncserver at boot , I havent tried them yet , but I would like to understand why my method isnt working
All suggestions gratefully received ;-)))
I'm assuming you are adding this code before the "exit 0" line? If you don't then your code will never be executed.

Cheers

Andrew.

Return to “Beginners”