solaris 11の環境で、シェルスクリプトを作成し実行テストをしたところ成功しました。
cronに登録してスケジュール実行させると失敗します。
原因不明の状況です。
■実行ユーザの権限 srdcsユーザ srdcs04% env USER=srdcs LOGNAME=srdcs HOME=/export/home/srdcs PATH=/bin:/usr/bin:/usr/ucb:/etc:.:/usr/sfw/bin/gcc:/export/home/srdcs/embulk_test/bin/embulk MAIL=/var/mail//srdcs SHELL=/bin/csh TZ=Japan LANG=ja TERM=xterm DISPLAY=localhost:14.0 PWD=/export/home/srdcs ■crontab設定 srdcs04% crontab -l 0,10,20,30,40,50 * * * * /bin/bash /export/home/xxxxxx/embulk_test/sh/bulkinsert_T_RS_TRAN.sh ■シェルスクリプト srdcs04% cat /export/home/xxxxxx/embulk_test/sh/bulkinsert_T_RS_TRAN.sh # # 環境変数設定 # export EMBULK_CMD="/export/home/xxxxxx/embulk_test/bin/embulk/embulk-0.9.15.jar run" export EMBULK_CONF="/export/home/xxxxxx/embulk_test/conf/config_incremental_T_RS_TRAN.yml.liquid" export EMBULK_DIFF="-c /export/home/xxxxxx/embulk_test/conf/diff_T_RS_TRAN.yml" export EMBULK_LOG="/export/home/xxxxxx/embulk_test/log/bulkinsert_T_RS_TRAN.log" export MAIL_CMD="/usr/sbin/sendmail" export mail_T_RS_TRAN_file="/export/home/xxxxxx/embulk_test/mail/mail_T_RS_TRAN_file" export CHECK_T_RS_TRAN_LOG="/export/home/xxxxxx/embulk_test/mail/check_T_RS_TRAN.log" export ERROR_CODE_001="Error" export TIME="`date '+%y/%m/%d %H:%M:%S'`" export MAIL_CMD="/usr/sbin/sendmail" export mail_T_RS_TRAN_file="/export/home/xxxxxx/embulk_test/mail/mail_T_RS_TRAN_file" export CHECK_T_RS_TRAN_LOG="/export/home/xxxxxx/embulk_test/mail/check_T_RS_TRAN.log" #export MAIL_LIST="/export/home/xxxxxx/embulk_test/mail/mail.list" export ADDR="xxx@xxx" export ERROR_CODE_001="Error" # # メールヘッダ部作成 # echo "=====================" >> ${mail_T_RS_TRAN_file} echo "DATE : ${TIME}" >> ${mail_T_RS_TRAN_file} echo "HOST : `hostname`" >> ${mail_T_RS_TRAN_file} echo "=====================" >> ${mail_T_RS_TRAN_file} echo "Message:" >> ${mail_T_RS_TRAN_file} # # バルクインサート実行 # ${EMBULK_CMD} ${EMBULK_CONF} ${EMBULK_DIFF} >> ${EMBULK_LOG} if [ $? -ne "0" ]; then echo "=====================" >> ${CHECK_T_RS_TRAN_LOG} echo "DATE : ${TIME}" >> ${CHECK_T_RS_TRAN_LOG} echo "Embulk command Error T_RS_TRAN_TABLE" >> ${CHECK_T_RS_TRAN_LOG} echo "Embulk command Error T_RS_TRAN_TABLE" >> ${mail_T_RS_TRAN_file} ${MAIL_CMD} -f embulk_srdcs04@jp.xxxxx.com ${ADDR} < ${mail_T_RS_TRAN_file} exit 1 fi echo "=====================" >> ${CHECK_T_RS_TRAN_LOG} echo "DATE : ${TIME}" >> ${CHECK_T_RS_TRAN_LOG} echo "Embulk command success T_RS_TRAN_TABLE" >> ${CHECK_T_RS_TRAN_LOG} # # ログファイルチェック # while :; do cat ${EMBULK_LOG} | grep "${ERROR_CODE_001}" >> ${mail_T_RS_TRAN_file} if [ $? = "0" ];then echo "=====================" >> ${CHECK_T_RS_TRAN_LOG} echo "DATE : ${TIME}" >> ${CHECK_T_RS_TRAN_LOG} echo "Embulk Log Error T_RS_TRAN_TABLE" >> ${CHECK_T_RS_TRAN_LOG} ${MAIL_CMD} -f embulk_srdcs04@jp.xxxxx.com ${ADDR} < ${mail_T_RS_TRAN_file} exit 1 else break fi done # # ログ整理 # echo "=====================" >> ${CHECK_T_RS_TRAN_LOG} echo "DATE : ${TIME}" >> ${CHECK_T_RS_TRAN_LOG} echo "Embulk Log success T_RS_TRAN_TABLE" >> ${CHECK_T_RS_TRAN_LOG} rm -r ${mail_T_RS_TRAN_file} exit 0 ■実行結果 srdcs04% tail -f check_T_RS_TRAN.log ===================== DATE : 19/03/05 15:00:00 Embulk command Error T_RS_TRAN_TABLE ■cronの権限 srdcs04% ls -ltrh /var/spool/cron/crontabs -rw------- 1 root xxxxxx 1.2K 3月 5日 15:20 srdcs
回答4件
あなたの回答
tips
プレビュー