linux - 获取刚刚启动的 screen session 的PID

标签 linux bash session pid gnu-screen

如何获取刚刚创建的 screen session 的 PID 喜欢:

screen -dm -S test ping localhost

screen -ls
There is a screen on:

3310.test       (09/04/15 14:07:41)     (Detached)

我要3310

我在看 Bash: Getting PID of daemonized screen session但它不适合我的需要。

我一直在努力

screen -dm -s test ping localhost | echo $! 

但是pid差了两个或一个

最佳答案

试试看:

screen -dm -S test ping localhost & echo $!

它在后台启动 screen 进程(带 -d 的 screen 无论如何都以“分离模式”启动)并打印其 PID。

关于linux - 获取刚刚启动的 screen session 的PID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29538038/

相关文章:

python - scrapy - 从响应/请求 header 获取cookie

java - 从Tomcat 6 JDK 1.6迁移到Tomcat 7 JDK 1.7 session 问题

c - 在 Linux 上测试内核 Crypto API

python - 从 python 脚本中将参数传递给 x-executable 文件

linux命令行使用提供的参数重命名所有文件

linux - 在 Linux 中快速列出目录中的随机文件集

bash - 在 GitHub Actions 中使用上下文表达式内的变量

PHP session 阻塞,忽略 session_write_close

编译 vsftpd 3.0.0 失败

c - 当EPOLLHUP看起来足够时,为什么我们需要EPOLLRDHUP?