I am trying to find specific service and I have question about this command:
service --status-all | grep worker
Why did service --status-all | grep ...
not work?
I am trying to find specific service and I have question about this command:
service --status-all | grep worker
Why did service --status-all | grep ...
not work?
There could be one of 2 issues here.
Either you have no process called worker - I didn't. Try to grep for kill
or dm
- you should see something for them.
You are seeing all of them. This is because it's giving it as lots of individual outputs, not just 1 thing.
Each of those lines is printed separately, and it's as stderr
not stdout
. You have 2 options.
Redirect to a file, like this:
service --status-all > allout.txt 2>&1
All the output will be saved in a file called allout.txt
. You can then cat and grep that:
cat allout.txt | grep worker
That can be combined to one command:
service --status-all > allout.txt 2>&1 && cat allout.txt | grep worker
Redirect stderr to /dev/null
, and grep stdout
:
service --status-all 2>&1 > /dev/null | grep worker
Both of these give the same output:
tim@Hairy14:~$ service --status-all > allout.txt 2>&1 && cat allout.txt | grep kill
[ ? ] killprocs
and
tim@Hairy14:~$ service --status-all 2>&1 > /dev/null | grep kill
[ ? ] killprocs
You can easily use the hack double Tab
once you run :
sudo service wo
then double Tab this would automcplete or list all services startting with wo
you can still use grep if your terminal support colors
for example here is a test for my services:
service --status-all | grep vnstat
Use:
service --status-all |& grep worker
service --status-all | grep vnstat