如何获取使用 nohup 运行的程序列表 [英] How to get a list of programs running with nohup

查看:44
本文介绍了如何获取使用 nohup 运行的程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 SSH 连接访问运行 CentOS(Linux 发行版)的服务器.因为我不能一直保持登录状态,所以我使用nohup [command] &"运行我的程序.

I am accessing a server running CentOS (linux distribution) with an SSH connection. Since I can't always stay logged in, I use "nohup [command] &" to run my programs.

我找不到如何获取我开始使用 nohup 的所有程序的列表.工作"仅在我注销之前有效.之后,如果我再次登录,jobs 命令什么也没有显示,但我可以在日志文件中看到我的程序仍在运行.

I couldn't find how to get a list of all the programs I started using nohup. "jobs" only works out before I log out. After that, if I log back again, the jobs command shows me nothing, but I can see in my log files that my programs are still running.

有没有办法获得我开始使用nohup"的所有程序的列表?

Is there a way to get a list of all the programs that I started using "nohup" ?

推荐答案

当我开始使用 $ nohup Storm dev-zookeper 时,

METHOD1 : 使用 jobs,

prayagupd@prayagupd:/home/vmfest# jobs -l
[1]+ 11129 Running                 nohup ~/bin/storm/bin/storm dev-zookeeper &

注意:jobs 仅在启动 nohup 的同一终端会话中显示 nohup 进程.如果您关闭终端会话或尝试新会话,它将不会显示 nohup 进程.首选方法2

NOTE: jobs shows nohup processes only on the same terminal session where nohup was started. If you close the terminal session or try on new session it won't show the nohup processes. Prefer METHOD2

METHOD2 : 使用 ps 命令.

METHOD2 : using ps command.

$ ps xw
PID  TTY      STAT   TIME COMMAND
1031 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1
10582 ?        S      0:01 [kworker/0:0]
10826 ?        Sl     0:18 java -server -Dstorm.options= -Dstorm.home=/root/bin/storm -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dsto
10853 ?        Ss     0:00 sshd: vmfest [priv] 

带有 ? => 的 TTY 列nohup 运行程序.

TTY column with ? => nohup running programs.

说明

  • TTY 列 = 与进程关联的终端
  • STAT 列 = 进程状态
    • S = 可中断睡眠(等待事件完成)
    • l = 是多线程的(使用 CLONE_THREAD,就像 NPTL pthread 一样)

    参考

    $ man ps # 然后搜索 /PROCESS STATE CODES

    这篇关于如何获取使用 nohup 运行的程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆