Linux 开机启动VNCserver

回眸只為那壹抹淺笑 提交于 2020-02-19 07:50:45

Debian开机启动VNC:

 

启动VNC并设置:

startjwm &
firefox --display=:1

 

### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
# The Username:Group that will run VNC
export USER="root"
#${RUNAS}
# The display that VNC will use
DISPLAY="1"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="x"
GEOMETRY="800x600"
#You Can Choice GEOMETRY="1024x768" && GEOMETRY="1280x1024"
# The name that the VNC Desktop will have.
NAME="Vncserver"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0

设置VNC开机启动

vim /etc/init.d/vncserver

 

 或者

vim /etc/init.d/vncstart

#! /bin/sh
export USER="root"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11"
NAME=vncstart
start()
{
    su - $USER -c"vncserver :0"
}
stop()
{
    su - $USER -c"vncserver -clean -kill :0"
}
case "$1" in
    start)
        echo -n "Starting Xvnc: "
        start
        ;;
    stop)
        echo -n "Stopping Xvnc "
        stop
        ;;
    restart)
        echo -n "Restarting Xvnc "
        stop
        start
        ;;
****)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
        ;;
esac
exit 0

添加权限

chmod +x /etc/init.d/vncserver

使配置生效

update-rc.d vncserver defaults

添加计划任务,定时重启vnc或者系统,以防止firefox假死不出分

crontab -e

当不想设置为开机启动时,运行:

rcconf

命令,去掉星号


CentOS开机启动VNC:

1.配置vnc

/etc/sysconfig/vncservers

2.shift+g 移到最后插入下面的代码

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"

3.设置vnc自动启动

chkconfig vncserver on

4.安装flash插件

wget http://blog.firetry.com/soft/libflashplayer.so
mkdir -p ~/.mozilla/plugins
cp libflashplayer.so ~/.mozilla/plugins/


5.下载vagex 插件,youtube优化插件

wget http://vagex-debian.googlecode.com/files/youtube_video_quality_manager-1.2-fx.xpi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!