4

I run this command

ss -tulpnoea|grep -i water|grep -v 127
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
.....

I tried with 2> /dev/null...

 ss -tulpnoea|grep -i water|grep -v 127 2> /dev/null
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    Failed to find cgroup2 mount
    .....

How to avoid the annoying message about cgroup2 mount? Distro is Slackware 15.0

2
  • The cgroup2 virtual filesystem is meant to be mounted on /sys/fs/cgroup, systemd takes care of that on systems that use it. Maybe you need to do it via /etc/fstab on Slackware? Jun 2 at 19:55
  • 2
    I'd say that's maybe a bug in ss (iproute2) – as long as it only uses cgroups for looking up some auxiliary info, it should not assume that cgroups are in use on the system at all, rather than complaining. Jun 3 at 8:44

1 Answer 1

13

You have your redirection at the wrong point in the pipeline. Presumably the error comes from the ss command, so that is where you should hide the error output. Or you can group the output and redirect from the command as a whole.

Here are some possible solutions to suppress any errors:

Redirect the standard error of the command producing the messages:

ss -tulpnoea 2> /dev/null|grep -i water|grep -v 127 

Run the commands in a subshell and redirect the standard error of the subshell:

(ss -tulpnoea|grep -i water|grep -v 127) 2> /dev/null

Group the commands and redirect the standard error of the group:

{ ss -tulpnoea|grep -i water|grep -v 127 ; } 2> /dev/null

Or if you specifically want to suppress that error and not others (subject to shell support)

ss -tulpnoea 2> >(grep -Fxv 'Failed to find cgroup2 mount' >&2)|grep -i water|grep -v 127) 
(ss -tulpnoea|grep -i water|grep -v 127) 2> >(grep -Fxv 'Failed to find cgroup2 mount' >&2)
{ ss -tulpnoea|grep -i water|grep -v 127 ; } 2> >(grep -Fxv 'Failed to find cgroup2 mount' >&2)
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .