Fun with /proc Directly view the kernel's running process table and system variables [Discuss (1) | Link to this hack]
Comments on this hack
Showing messages 1 through 1 of 1.
Cheking discrepencies between ps and /proc
2004-11-06 04:25:22
stcDenis
[View]
To check ps, the correct command should have been: ls -d /proc/* | grep '[0-9]' | wc -l; ps ax | wc -l
Notice the quotes to protect the regexp. This may help avoid a common shell gotcha. Using bash, if you have a file matching the regexp in your cwd, the shell substitute your pattern with this file name, and the result is than unexpected.
Alternatively, I thought that ls /proc | grep ^[0-9] | wc -l; ps ax | wc -l
may be better since it use an anchored regexp. Here quote are also not required, bash only understand really simple regexp.
ls -d /proc/* | grep '[0-9]' | wc -l; ps ax | wc -lNotice the quotes to protect the regexp. This may help avoid a common shell gotcha. Using bash, if you have a file matching the regexp in your cwd, the shell substitute your pattern with this file name, and the result is than unexpected.
Alternatively, I thought that
ls /proc | grep ^[0-9] | wc -l; ps ax | wc -lmay be better since it use an anchored regexp. Here quote are also not required, bash only understand really simple regexp.