2012-11-21 39 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有不同的选项。