1

I have inherited responsibility for a RHEL 5 development box we are using at work that has been configured using a VNC server to allow multiple users to work on the machine at once.

The VNC service seems to have been configured along the lines of this post http://it.megocollector.com/?p=1300 so that it runs at boot and creates a set of predifened user desktops specified in /etc/sysconfig, great! However, occasionally it is necessary to add a new user, or start/stop/restart the service for an existing user. At the moment the only way we can do this is to start/stop/restart the VNCservice for all users, how can I do this for just the user in question?

Thanks!

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
Earl Sven
  • 187
  • 1
  • 3
  • 11

1 Answers1

3

There is a session number for each user which is config in /etc/sysconfig/vncserver, for example:

VNCSERVERS="2:quanta"

You can use this number to start, stop a separate vnc session, something like this:

vncserver :2
vncserver -kill :2

Edit

You can custom the init script to make it can start a separate session, something as belows:

function start() {
    SESSION=$1
    ...
    vncserver :${SESSION} ${VNCSERVERARGS[${SESSION}]}
}

And in the start) of case statement, you can check the number of parameters to decide whether starting all or individual session:

if [ -n "$2" ]; then
    start $2
else
    for display in ${VNCSERVERS}
    do
        start $display
    done
fi
quanta
  • 51,413
  • 19
  • 159
  • 217
  • True, this does work however it simply starts a vanilla vnc session on the numbered port as the user executing the command, it doesn't load the additional configuration (eg custom resolutions/users) that we have specified in /etc/sysconfig. We can start the server as a particular user using su to first change to that user in terminal, however none of the other options configured are used. Is there a way to start the numbered server using the configuration in /etc/sysconfig as well? Thanks! – Earl Sven Aug 08 '11 at 09:53
  • You can append it to the end of command: `vncserver :2 -geometry 800x600 -nolisten tcp -nohttpd -localhost`. – quanta Aug 08 '11 at 10:26
  • Yes but surely this defeats the point of defining the options in the configuration file? – Earl Sven Aug 08 '11 at 10:44
  • I've edited my above post to answer your question. – quanta Aug 08 '11 at 11:17