Command failed in Command_line sensor

Hello,

When i use the following command_line sensor:

  - platform: command_line
    name: readsensorspy
    command: "ps -aef | grep -i 'python3.9 /home/pi/readsensors.py'"
    scan_interval: 30
    value_template: '{%if value.split("/usr/local/bin/python3.9")[1] == Null%} crashed {% else%} active {% endif%}'

i get the following error:
2021-09-07 14:17:16 ERROR (SyncWorker_19) [homeassistant.components.command_line] Command failed: ps -aef | grep -i 'python3.9 /home/pi/readsensors.py'

What am i doing wrong?

I finally figured out a solution. use ps x and not ps -aex.

My configuration:

- platform: command_line
    name: readsensorspy
    command: "ps x | grep -i 'python3.9 /home/pi/readsensors.py'"
    scan_interval: 30
    value_template: '{%if value.split("/usr/local/bin/python3.9")[1] == Null%} crashed {% else%} active {% endif%}'