「ps -ef」中未列出進程 (AIX 7.1)

「ps -ef」中未列出進程 (AIX 7.1)

ps -ef我遇到一個涉及AIX 7.1 上命令輸出的不尋常問題。

shell 腳本透過解析此輸出來監視進程。我注意到有兩次這個清單中省略了一個進程(一個 Perl 程式)。我讀到的有關該主題的所有內容都表明這是不可能的。該程式在早上 6 點透過 crontab 啟動,一直運行到晚上 11 點,然後自行終止。我ps -ef在監視器腳本省略後立即檢查了輸出,它顯示:

user  1249864  9569338   0 06:00:00   -  0:19 /usr/bin/perl -w /path/to/omittedProgram.pl

……這意味著它與早上 6 點開始的過程相同。程式沒有終止,然後重新啟動。

是什麼導致它從輸出中被省略ps -ef

該程式檢查 的輸出ps -ef,已成功運行了大約五年。我只注意到這個問題兩次,但都是在過去兩個月出現的:

# set global variables
PROCESS_FILE=/tmp/processList.txt
TEMP_FILE=/tmp/greppedProcesses.tmp
BOX=`uname -n`
DATE=`date`
EMAIL_LIST="[email protected]"

# Get list of running processes
ps -ef > $PROCESS_FILE

checkProcess() {
  PROCESS_NAME=$1
  PROCESS_ABBREVIATION=$2
  PROCESS_COUNT=$3
  UNIQUE_PROCESS_IDENTIFIER=$4

  GREPPED_LINES=$TEMP_FILE-$PROCESS_ABBREVIATION
  grep $UNIQUE_PROCESS_IDENTIFIER $PROCESS_FILE | grep -v grep > $GREPPED_LINES
  NUM=`cat $GREPPED_LINES | wc -l`
  if [[ $NUM -ne $PROCESS_COUNT ]]
     # Incorrect number of processes running!
     then MESSAGE=`printf "The \"$PROCESS_NAME\" process count is %1d, but it should be $PROCESS_COUNT!!!" $NUM`
          echo "Monitor - starting on $DATE\n\n$MESSAGE\n\n`cat $GREPPED_LINES`" | mail -s "Problem with $PROCESS_NAME on $BOX" $EMAIL_LIST
  fi
  # Delete the temp file
  rm $GREPPED_LINES
}

checkProcess "Full Name of Program" "Program Abbreviation" <expected number of processes running> "Unique string to identify program in ps output"
checkProcess ... (for other processes) ...

exit 0

另外,我們安裝的 AIX 沒有pgrep.

相關內容