This is basically my script.#!/bin/sh#set -xPATH=/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.txtMINUTE=`cat stgstatus.txt |grep traffic |awk '{print $2}' |cut -d| -f1`if [ $MINUTE -eq 0 ];then    /opt/stg/5.0/bin/ctl restart allfiHowever when crontab tried to run it, it will always have this error. I didn't have any whoami command in my script, why the error appeared? From stg Sat May  2 19:49 MYT 2015To: stgSubject: Output from cron commandMIME-Version:Content-Type:Content-Length:Your cron job on ckpgumb10/var/tmp/checkstgstatus.shproduced the following output:/opt/stg/5.0/bin/ctl[906]: whoami:  not foundThis is how my crontab looks like.49 * * * * /var/tmp/checkstgstatus.shEDIT #1The format of temporary file, stgstatus.txt looks like below.# | Handler      | Mode         |    PID | Start Time | CPU time | Command============================================================================== 1 | stg_d7       | standard     |  14998 |     May_01 |    00:00 | /opt/stg/5.0/bin/daemonDetailed stg_d7 status (stg_d7status):0 - IWU runningrelease SunOS5.10 5.0.0.70node ckpgumb10 172.19.144.181started 2015.05.01 20:04:39traffic 0|0|32768 (last minute|hour|day)end of detailed status, stg_d7status returned 0 (all ok) 2 | tcapproxy    | standard     |  15105 |     May_01 |    09:25 | java   |              |              |  15102 |     May_01 |    00:04 | lsr-relayDetailed tcapproxy status (tcapproxystatus):05/02/15-19:30:05 TcapProxy is running.end of detailed status, tcapproxystatus returned 0 (all ok)
How to overcome this error when running a script in crontab?
cron