通过 cron 启动 xterm 窗口

通过 cron 启动 xterm 窗口

我在 Ubuntu Server 12.04 上使用 cron 安排系统在午夜自动重启,并在重启时执行一个脚本,该脚本启动 vnc 服务器并打开八个终端窗口并在每个窗口中运行一个命令。我使用 tightvncserver 作为我的 vnc 服务器,使用 xterm 作为我的终端仿真器,使用 openbox 作为我的桌面环境。我将 cron 指令存储在 root 的 crontab 中,因此脚本以 root 身份运行。问题是,当我以 root 身份从 ssh 打开 xterm 会话时,它说显示未设置。我使用的是命令:“xterm -hold -geometry 52x4+0+0 -e /PM1/start.sh”。vncserver 早些时候以 root 身份在同一个脚本中启动。非常感谢您的帮助。

答案1

在远程服务器安装xauth可以解决问题。

sudo apt-get install xauth

安装 xauth 后您可能需要重新启动服务器。

还要检查服务器端的 sshd_config 文件X11转发应设置为是的

/etc/ssh/sshd_config

另外,通过 ssh 连接时,您应该使用 -X 选项来启用 Xforwarding。例如:

ssh -X [email protected]

相关内容