2012-11-21 21 views
0

時,我從殼(tcsh的)這個命令,它執行perfectly-錯誤而

cal | tail -6 | sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' | tr -s '[:blank:]' '\n' | head -21 | tail -20 | tr -s '\n' ' ' | grep -w `date "+%e"` ; /usr/bin/bash -lc "if [ "$?" == 0 ] ; then echo xyz ; fi" 

但是當我把同樣的事情在一個crontab,我得到從這個錯誤的郵件我的機器

Subject: Output from "cron" command 
Content-Length: 244 

Your "cron" job on uatserver 
cal | tail -6 | sed -e 's/^.\{3\}//' -e 's/.\{3\}$//' | tr -s '[:blank:]' '\n' | head -21 | tail -20 | tr -s '\n' ' ' | grep -w `date "+ 

produced the following output: 

Usage: grep -hblcnsviw pattern file . . . 

我敢肯定,連我的crontab命令使用tcsh作爲它被設置爲默認執行。

p.s-我的機器: 的SunOS uatserver 5.10 Generic_127112-11了i86pc I386了i86pc

回答

2

您的問題是PATH變量是不一樣的。 Solaris提供的grep的 例子不同的口味:

在/ usr /斌/ grep的 在/ usr/XPG4 /斌/ grep的

你的crontab運行的/ usr /斌/ grep的,而不是在/ usr/XPG4 /斌/ grep的。兩個版本的grep有不同的選項。