为什么我的 .screenrc 只触发打开 2 个屏幕?

Dar*_*ein 1 linux mac-osx gnu-screen

我的 .screenrc 文件中有以下内容:

# Don't display the copyright page
startup_message off

# keep scrollback n line
defscrollback 5000

# setup some screens
screen -t top 0 top -o cpu -s 5
screen -t mysql 1 mysql -u root -p
screen -t shell_screen 2 cd ~/webroot
screen -t report_gen 3 tail -f ~/webroot/path/report_gen_log.txt

shelltitle "$ |bash"

#change the hardstatus settings to give an window list at the bottom of the
##screen, with the time and date and with the current window highlighted
hardstatus             alwayslastline
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
Run Code Online (Sandbox Code Playgroud)

当我启动 screen 时,只创建了前 2 个屏幕。

可能有什么问题?

我正在运行 OSX,但我认为这并不重要。

Ian*_*and 8

凯尔是对的——屏幕窗口 2 将失败,因为 cd 是一个内置的 shell。即使它是一个命令,它也会立即终止,并且 screen 会关闭该窗口。

你可以做这样的事情来让它工作:

screen -t shell_screen 2 bash -c "cd ~/webroot && bash"
Run Code Online (Sandbox Code Playgroud)

由于“~”字符,tail 命令(窗口 3)失败。Screen 不进行外壳式扩展,因此 tail 立即失败(无法打开文件)并终止,并且屏幕窗口被关闭。手动将 ~ 扩展到您的主目录的完整路径,该屏幕应该可以工作。

  • +1 为了更好的答案:-) (2认同)
  • 尾部问题的一个补充:我建议使用“-F”而不是“-f”,因为即使文件被重命名、滚动等,它也会继续拖尾 (2认同)