Changes between Initial Version and Version 1 of jazz/13-04-09


Ignore:
Timestamp:
Apr 9, 2013, 11:26:14 AM (11 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jazz/13-04-09

    v1 v1  
     1= 2013-04-09 =
     2
     3== Shell Script ==
     4
     5 * 今天有人問我怎麼分辨同一支 script 是手動執行,還是 cron job 執行呢?
     6 * 雖然 ENV 環境變數本身就有很多不同,但想來想去,覺得判斷 parent pid 是否等於 cron 會是比較恰當的方式。
     7 * Shell Script 中找到目前程序的 parent process id 是使用 $$
     8 * 可是如果想要取得目前 Shell 的 parent process id 則可以使用 $PPID
     9 * [參考] http://www2.linux-training.be/funhtml/ch14s02.html