Why use ps -ef check the process every time the pid will change? I use the ps -ef to check the process, but every time the pid will change, you see the below, 1726-> 1728->...

aircraftdeMacBook-Pro:etc ldl$ ps -ef | grep safira
  501  1726   527   0 10:14上午 ttys000    0:00.00 grep safira
aircraftdeMacBook-Pro:etc ldl$ ps -ef | grep safira
  501  1728   527   0 10:14上午 ttys000    0:00.00 grep safira
aircraftdeMacBook-Pro:etc ldl$ ps -ef | grep safira
  501  2298   527   0 11:18上午 ttys000    0:00.00 grep safira
aircraftdeMacBook-Pro:etc ldl$ ps -ef | grep safira
  501  2301   527   0 11:18上午 ttys000    0:00.00 grep safira
Every time you run this in Terminal two new processes for ps and grep are created, run to do their job and then terminated successfully. So each invocation gets new PIDs. 



To properly exclude the process grep search_string from grep'ing for search_string in the ps result use:

ps -ef | grep -v grep | grep search_string


or

ps -ef | grep [s]earch_string


e.g. ps -ef | grep -v grep | grep safira or ps -ef | grep [s]afira