1

Starting tightvncserver manually from a terminal works fine. To start it @reboot I am using crontab -e with the following command:

@reboot sleep 20 && /usr/bin/tightvncserver

The path is correct, I tested it using which tightvncserver, but it does not work. I am new to cron, so I do not have experience. What comes to my mind, that there is trouble with the users. Cron does not know, which user should execute this command.

Any help is appreciated!

3
  • See raspberrypi.stackexchange.com/a/39374/8697 - while this mentions Jessie it works with Stretch (or any systemd OS).
    – Milliways
    Commented Jan 20, 2018 at 23:12
  • @Milliways: Thank you very much for your link. This line in cron "at"reboot sudo -u pi /usr/bin/tightvncserver" works for me, but I am not really happy with it. Tightvncserver is an executable which is able to work without sudo. However, "at"reboot -u pi /usr/bin/tightvncserver or "at"reboot pi /usr/bin/tightvncserver, "at"reboot /usr/bin/tightvncserver do not work.
    – cerv21
    Commented Jan 21, 2018 at 15:11
  • @Milliways: Edit: su is what I want. I only knew that su is used for root, but I was not familiar with its options.
    – cerv21
    Commented Jan 21, 2018 at 15:14

2 Answers 2

0

You can start tightvncserver at startup by adding the line into /etc/rc.local.

rc.local starts after all the services are up after the OS start.

Here is rc.local from Raspberry pi documentation.

2
  • Thank you, but I would like to use cron. I something goes wrong, I have to replace @reboot with some interval of time, such that cron seems to be the better option for me.
    – cerv21
    Commented Jan 21, 2018 at 15:06
  • @opens rc.local is your best option but if you want to use some other option, it will be your choice. As you have already mentioned you have tried to use cron but it did not function for you. Commented Jan 22, 2018 at 2:03
2

This is how I get it done with cron:

sudo crontab -e

add the line

@reboot su - pi -c '/usr/bin/tightvncserver :1'

This works flawlessly and doesn't come up with the "no pid" error.

Your Answer

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

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