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
精彩评论