我正在试图找到进程的PID (motion_sensor.py),但是pgrep什么也不返回。为什么它不返回进程id?
pgrep -u www-data motion_sensor.pyps -ef \ grep "motion_sensor“返回
root 7149 1 93 Apr25 ? 15:59:08 python motion_sensor.py
www-data 31872 23531 0 14:09 ? 00:00:00 sh -c sudo python /home/pi/Desktop/PiControl/motion_sensor.py
root 31873 31872 0 14:09 ? 00:00:00 sudo python /home/pi/Desktop/PiControl/motion_sensor.py
root 31874 31873 47 14:09 ? 00:14:30 python /home/pi/Desktop/PiControl/motion_sensor.py
pi 32645 32202 0 14:39 pts/0 00:00:00 grep --color=auto motion_sensor.py发布于 2015-04-26 14:45:42
通常,pgrep将搜索模式应用于处理名称。本例中的进程名是python,而不是motion_sensor.py。如果希望grep获得完整路径,而不仅仅是进程名,则需要传递-f。
pgrep -u www-data -f motion_sensor.py发布于 2015-04-26 15:09:40
所需的是查找进程的PID,因此您可以尝试:
ps aux x grep www-data motion_sensor.py
https://stackoverflow.com/questions/29879057
复制相似问题