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