在 crontab 中运行脚本时如何克服此错误?

在 crontab 中运行脚本时如何克服此错误?

这基本上就是我的脚本。

#!/bin/sh
#set -x

PATH=/usr/jdk/instances/current/bin:/usr/bin:/bin:/opt/ss7/access/bin:/opt/ss7/sgc/bin:/opt/ss7/access/install:/opt/ss7/sgc/install:/usr/jdk/instances/current/bin:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/ccs/bin:/usr/openwin/bin:/usr/ucb:/opt/stg/5.0/bin:/opt/stg/5.0/tools

/opt/stg/5.0/bin/ctl status all > stgstatus.txt

MINUTE=`cat stgstatus.txt |grep traffic |awk '{print $2}' |cut -d"|" -f1`

if [ $MINUTE -eq 0 ];then
    /opt/stg/5.0/bin/ctl restart all
fi

但是当 crontab 尝试运行它时,它总是会出现此错误。我的脚本中没有任何whoami命令,为什么会出现错误?

From stg Sat May  2 19:49 MYT 2015
To: stg
Subject: Output from "cron" command
MIME-Version:
Content-Type:
Content-Length:

Your "cron" job on ckpgumb10
/var/tmp/checkstgstatus.sh

produced the following output:

/opt/stg/5.0/bin/ctl[906]: whoami:  not found

这就是我的 crontab 的样子。

49 * * * * /var/tmp/checkstgstatus.sh

编辑#1

临时文件 stgstatus.txt 的格式如下所示。

# | Handler      | Mode         |    PID | Start Time | CPU time | Command
==============================================================================
 1 | stg_d7       | standard     |  14998 |     May_01 |    00:00 | /opt/stg/5.0/bin/daemon
Detailed stg_d7 status (stg_d7status):
0 - IWU running
release SunOS5.10 5.0.0.70
node ckpgumb10 172.19.144.181
started 2015.05.01 20:04:39
traffic 0|0|32768 (last minute|hour|day)

详细状态结束,stg_d7status 返回 0(一切正常)

 2 | tcapproxy    | standard     |  15105 |     May_01 |    09:25 | java
   |              |              |  15102 |     May_01 |    00:04 | lsr-relay
Detailed tcapproxy status (tcapproxystatus):
05/02/15-19:30:05 TcapProxy is running.
end of detailed status, tcapproxystatus returned 0 (all ok)

相关内容