2012-04-11 6 views
2

수동으로 실행되지만 cronjob을 실행할 때 원하는 출력을 얻지 못하는 스크립트가 있습니다. 스크립트에 문제가 있으면 알려주십시오. Admin's Choice에서Cronjob 스크립트가 실패하지만 수동으로 정상적으로 실행됩니다.

#!/usr/bin/ksh 

file1=$(find *-* -mtime 1) 

file2=$(find *-* -mtime 2) 


basefile1=$(basename $file1) 
basefile2=$(basename $file2) 


cd /gtxappl/Release/SCMAudit 

./cmp.sh $basefile1 $basefile2 > dailyAuditChecks.txt 

mailx -s "Daily Checks Report" ****@homeretailgroup.com < dailyAuditChecks.txt 

답변

4

:

 
5. Crontab Environment 
cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh). 
cron supplies a default environment for every shell, defining: 
HOME=user’s-home-directory 
LOGNAME=user’s-login-id 
PATH=/usr/bin:/usr/sbin:. 
SHELL=/usr/bin/sh 
Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry. 

나는 가능한 절대 경로를 사용하는 것이 좋습니다 당신이 환경 변수를 필요한 경우의 .profile을 실행에 대해 잊지 마세요.

+0

의심 스럽다면 printenv 명령을 스크립트에 추가하여 환경이 실제로 어떻게 보이는지 확인하십시오. –

관련 문제