天天看點

71、shell中crontab中執行指令的特殊性,/bin/sh

1、在執行crontab指令時,與直接在shell中執行程式有點差別,要引起注意。如ps aux | grep file

直接在shell中執行,則搜尋範圍隻在top中目前執行的程序,而寫入crontab執行,則crontab中所有語句也成為了搜尋範圍。

count = `ps aux | grep file | wc -l`

2、寫的腳本前面加/bin/sh

如果要用給腳本執行權限的話,第一行必須聲明該腳本由什麼來解釋。比如:

#! /usr/local/php/bin/php

#! /bin/sh

效果如同:/bin/sh Scriptname

"#! /bin/sh"是對shell的聲明,說明你所用的是那種類型的shell及其路徑所在。可以了解為#!為特殊聲明符。

參考

【2】 關于/bin/sh

<a href="http://www.cnblogs.com/ghj1976/archive/2010/07/12/1775860.html">http://www.cnblogs.com/ghj1976/archive/2010/07/12/1775860.html</a>