0

Hi I wrote a script to start my vncserver when I call it manually via command line. It works as follows:

  • the script is in usr/bin I gave it the right authorization (chmod u+x startvnc)
  • but wen I test it via cron (* * * * * /usr/bin/startvnc) it doesn't works
  • In the syslog I find : "grandchild #8076 failed with exit status 2"

I'm on a VPS running Debian my VNC is TightVNC.

2
  • Without the contents of the script or any error messages, not much can be said. In any case the environment in cron is different from simply starting the script in the shell. DId you look up what the exit status might mean? You could run the script from cron using bash -x and redirect to a file to see what might be causing trouble.
    – Marki
    Sep 9, 2013 at 18:18
  • Instead of starting /usr/bin/startvnc from cron, you should start a script that does this, watching that keeps running, then restart it.
    – ott--
    Sep 9, 2013 at 18:45

1 Answer 1

0

Why are you going to be running the cronjob continually? Does the script detect if the vnc is currently running and only starts it up if it is not?

If you want vnc to just start up at reboot, use the @reboot cronjob, or put it inside /etc/rc.local.

Not knowing what your use case is or what your script actually does it is hard to assist you with fixing the issue, more information will be needed if the above does not solve your question.

5
  • Hi I want to run it because sometimes the VNC Stop (I dont know why) and it's a big problem cause I use it to make screencapts . The script is just two line #!/bin/sh and vncserver -geometry 1200x2200 :2
    – Romuald
    Sep 9, 2013 at 17:28
  • To prevent the VNC from spawning tons of processes, you should run a check to see if the VNC process is already running. If it is not running, then start it. As far as to why the script is not working, well it could be simply that too many VNC processes have started. I would look at your logs and see what the real reason is.
    – Jim
    Sep 9, 2013 at 17:31
  • 1
    The script is running, but it's most likely not finding the vncserver executable because you don't have a PATH set in the cron environment. Please, before fixing that part of the script, add logic to do as Brad says and detect whether vncserver is already running or not.
    – John
    Sep 9, 2013 at 17:49
  • Completely spaced the PATH bit, thanks John for pointing that out.
    – Jim
    Sep 9, 2013 at 17:51
  • Yes testing the pid number before start the vnc is a good idea. About PATH But I nerver head about this. So I am googleing this and make some test ( before I want to fully andersatand ) as PATH could impact all the cronjob in may list. Thanks
    – Romuald
    Sep 9, 2013 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .