'salt cmd.run if no result dont return ERROR: non-zero exit code

I am running a command on my salt master that checks if a process is running, if it is not running the output i get is:

ERROR: Minions returned with non-zero exit code

I tried adding >/dev/null to the end of my salt command which stops the error but this means i get no output if my process is running which is no good as i need to do something with the output if it is running.

Is there a way i can stop this Error being returned but keep the output returning when there is any?



Solution 1:[1]

You can redirect the stderr to /dev/null

salt '*' test.ping 2>/dev/null 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viet Do