脚本在 cron 中不起作用但可以在命令行中起作用

脚本在 cron 中不起作用但可以在命令行中起作用
#!/bin/sh
# Script to start multi-user session of MFG/PRO

# tokens:
# &DLC = Progress Directory
# &CLIENT-DB-CONNECT = command line to connect to each db in dbset

stty intr '^c'
DLC=/apps/2012ee/oe102b;export DLC
. $DLC/bin/slib_env
#PATH=$PATH:$DLC/bin;export PATH
export PATH="apps/2012ee/oe102b:/apps/2012ee/oe102b/bin:/usr/java/jdk1.5.0_15:/usr/java/jdk1.5.0_15/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/apps/2012ee/oe102b/bin:/home/mfg/batch_scripts/batchupi/batchupi.sh"
PROMSGS=$DLC/promsgs;export PROMSGS
PROTERMCAP=$DLC/protermcap;export PROTERMCAP
PS1='$$ ';export PS1
PROPATH=.,/apps/2012ee/qdt/envs/rkiftrn/configs,/apps/2012ee/rkiftrn/qxtend,/apps/2012ee/rkiftrn/cust,/apps/2012ee/rkiftrn/cust/xrc,/apps/2012ee/rkiftrn/cust/src,/apps/2012ee/rkiftrn,/apps/2012ee/rkiftrn/src,/apps/2012ee/rkiftrn/xrc,/apps/2012ee/rkiftrn/src/us,/apps/2012ee/rkiftrn/xrc/us,/apps/2012ee/rkiftrn/src/us/bbi,/apps/2012ee/rkiftrn/xrc/us/bbi,/apps/2012ee/rkiftrn/us,/apps/2012ee/rkiftrn/us/bbi,/apps/2012ee/rkiftrn/fin/customization,/apps/2012ee/rkiftrn/fin/proxypatch,/apps/2012ee/rkiftrn/fin/proxy.pl,/apps/2012ee/rkiftrn/fin,/apps/2012ee/rkiftrn/qra/qra.pl,/home/mfg/batch_scripts/batchupi; export PROPATH

#
# Set terminal type.
#
TERM=vt100 ; export TERM 
#
# Start MFG/PRO.
# 
# change to home directory
cd /home/batch_output/train

# exec $DLC/bin/_progres &DB etc
$DLC/bin/_progres -s 512 -mmax 16000 -inp 32000 -tok 20000 -TB 31 -TM 32 -Bt 10000 -rereadnolock -c 30 -D 100 -nb 200 -noshvarfix -pf /apps/2012ee/qdt/envs/rkiftrn/scripts/base-live-set.pf -cpinternal 620-2533 -cpstream 620-2533 -p /home/mfg/batch_scripts/batchupi/xxupicim.p


10 14 * * *     /home/mfg/batch_scripts/batchupi/batchupi.sh

答案1

crontab 中的环境与命令行中的用户 mfg 中的环境不同。按如下方式更改 crontab 条目:

10 14 * * *   su - mfg -c '/home/mfg/batch_scripts/batchupi/batchupi.sh'

您还可以在 crontab 文件中调整一些环境变量

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.oCXlYZ/crontab installed on Wed Jan  1 12:11:49 2017)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root@localhost

相关内容