Este é basicamente meu roteiro.
#!/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
No entanto, quando o crontab tentou executá-lo, ele sempre terá esse erro. Eu não tenho nenhum comando whoami
no meu script, por que o erro apareceu?
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
É assim que meu crontab se parece.
49 * * * * /var/tmp/checkstgstatus.sh
EDIT # 1
O formato do arquivo temporário, stgstatus.txt, é semelhante a seguir.
# | 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)
fim do estado detalhado, stg_d7status retornou 0 (tudo ok)
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)
Tags cron