-2

How can I run VNC on each boot?

Note: I use TightVNC server and Raspberry Pi 4 and Raspbian Buster

4
  • Do you use vncserver or Xvnc to start it manually? If vncserver - do you use any parameters? Any reason you are not using the default as that works and can connect over the Internet without opening ports (just interested)?
    – user115418
    Aug 10, 2020 at 15:54
  • yes I use 'vncserver :1' to start it Aug 10, 2020 at 16:46
  • That's the only thing you enter from the command line to start it? No sudo required? Have you considered a cron job to start at boot - or a systemd service def?
    – Seamus
    Aug 11, 2020 at 13:28
  • yes. that is only thing I do Aug 11, 2020 at 13:41

2 Answers 2

2

There are 2 ways you could do this.

Cron:
You can edit the crontab by typing this in the terminal: crontab -e. Then you should add this line to it @reboot vncserver :1.
Read the Cron docs here: https://www.raspberrypi.org/documentation/linux/usage/cron.md

Systemd (I'm not a 100% sure about the exact instructions but I think this is how you would do it.):
Type sudo nano /lib/systemd/system/vncstart.service. Add this to the file:

[Unit]
Description=Start VNC
After=multi-user.target

[Service]
ExecStart=/usr/bin/vncserver :1

[Install]
WantedBy=multi-user.target

Then enter:

sudo systemctl daemon-reload
sudo systemctl enable vncstart.service

Read the systemd docs here: https://www.raspberrypi.org/documentation/linux/usage/systemd.md

After you're done with one of these reboot to check if it's working.

0

If you REALLY want to use TightVNC server see:- https://raspberrypi.stackexchange.com/a/39374/8697

I wouldn't bother; The RealVNC included with Raspberry Pi OS is simpler and has many advantages.

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