Processes in Linux


I am using Inspec to test a process running on the Linux system. However, even though the process is running, it still shows that it doesnt exist. I checked the source code for the processes resource and saw that they run the ps axo command and extract the 11 field to the command parameter. However, my process is preceded by grep --color=auto. Hence it is actually grep which is adding to the 11th field. Is there any workaround to this problem?


Hi @poornimas,

As workaround you could use the command resource


as @simark said you could use command resource.!!!

For Example:
describe command('ps -ef | grep chef-client') do
    its('exit_status') { should eq 0 }


Yea. Thanks… That works.


I think you need to remember to grep out the grep, otherwise it will always find “chef-client” in the ps query:

aspitzer@jumpnt1:~/ > ps -ef | grep chef-client
aspitzer 14214 61615 0 14:40 pts/29 00:00:00 grep chef-client
aspitzer@jumpnt1:~/ > echo $?

aspitzer@jumpnt1:~/ > ps -ef | grep -v grep | grep chef-client
aspitzer@jumpnt1:~/ > echo $?


The “pgrep” and “pkill” tools are you rfriends for organizing this kind of process detection and parsing.


Yup. I realized that too. The process is actually not running. It is just the grep that was being displayed.