开发者

/proc directory script

开发者 https://www.devze.com 2023-02-23 19:10 出处:网络
I\'m looking for a ruby script that accesses the /proc directory and saves the process ID and command line (cmdline) information 开发者_如何学Goin a file.you may want to call ps instead of going to /p

I'm looking for a ruby script that accesses the /proc directory and saves the process ID and command line (cmdline) information 开发者_如何学Goin a file.


you may want to call ps instead of going to /proc.

cmd=`ps -eo pid,cmd`
o = File.open("output","w")
o.write(cmd)
o.close


you can also run below one liner bash script and redirect its output anywhere, as well as choose required argument option for head command.

ls -alR /proc/$(ls /proc/ |grep -i '[0-9]'|sort -n|head ) > /proc_open_files
0

精彩评论

暂无评论...
验证码 换一张
取 消