My Shell Script Help
顯示具有
control
標籤的文章。
顯示所有文章
顯示具有
control
標籤的文章。
顯示所有文章
2015年2月12日 星期四
return value from shell script
ref: http://tldp.org/LDP/abs/html/exit-status.html
是用 exit 指令。
exit 123
然後 caller 用 $? 就可以取得上一個 script exit 的值。
2013年12月24日 星期二
cron 的一些.. run as XXX 還有環境
cron 是定時執行的 daemon。
命令是在;
/etc/crontab
在crontab 中可以指定以哪一個 user 的身份來 run command
但是並不包含該 user 環境變數。
所以 run 起來會和真的以該user run 該 script 的結果不同。
為了解決這個問題,
可以在 command script 的開頭加入:
. .profile
https://gist.github.com/checko/8119870
2011年5月31日 星期二
Stop on Error
shell script default 是在有 Error 時也不會停下來。
如果要在有任何 error 時停下來,可以用
set -e
如果之後又不需要了 (有 error 也不用停),可以再用
set +e
ref :
http://www.linuxjournal.com/node/1005733
較舊的文章
首頁
訂閱:
文章 (Atom)