首先确保vnc server已经装好(可参考我上一篇博客)
在/etc/文件下,新建vncserver文件夹,在vncserver文件夹下新增两个文件startvnc.py和startvnc.sh,两个文件内容分别为:
startvnc.py:
import sys import os user=["k40","wcg","szh","zf","yry","lxy","llp"] #不同账户的用户名,port按这个顺序依次是1到7,如:k40即port 1 i = 1 depth = "16" geometry = "1024x900" #分辨率 name = "vncserver" for name in user: options = "-name %s -depth %s -geometry %s :%d" % (name, depth, geometry, i) print(options) i = i + 1 cmd = "su %s -c '/usr/bin/vncserver %s'" % (name, options) print(cmd) os.system(cmd)
startvnc.sh:
#!/bin/bash python /etc/vncserver/startvnc.py exit 0
然后重启电脑