我是 shell 编程的新手。假设我已经从我的终端启动了一个程序(例如 NetBeans),如果我输入
ps aux|grep netbeans
Run Code Online (Sandbox Code Playgroud)
我得到输出
pre 18775 1.2 0.0 12524 1972 pts/3 S 20:17 0:00
Run Code Online (Sandbox Code Playgroud)
其中 18775 指定进程的 PID 等。
然后我用杀了它
kill 18775.
Run Code Online (Sandbox Code Playgroud)
NetBeans UI 在其上消失。如果我尝试使用第一个命令获取 pid,我仍然会得到:
pre 19137 0.0 0.0 9136 1068 pts/3 S+ 20:19 0:00 grep --color=auto netbeans
Run Code Online (Sandbox Code Playgroud)
如果进程已经被杀死,为什么它仍然显示上述输出?
我目前正在使用
top -b -d 1 > file1.csv
Run Code Online (Sandbox Code Playgroud)
将整个输出附加到一个 csv 文件。但是,我希望单独在 file1 中输入 Cpu(%us) 字段。我已经到了这个程度:
top -b -d 1|grep Cpu
Run Code Online (Sandbox Code Playgroud)
在那里我只能查看 Cpu 条目。
当我尝试
top -b -d 1|grep Cpu > file1.csv
Run Code Online (Sandbox Code Playgroud)
它认为不起作用,因为我什至无法查看我的文件。
我的目的是为所有 CPU 值(存储在 csv 文件中)动态绘制 LiveGraph。谢谢!