【问题标题】:return code 999 error while executing the shell script through crontab通过 crontab 执行 shell 脚本时返回代码 999 错误
【发布时间】:2020-11-19 07:09:14
【问题描述】:

我创建了一个连接到 teradata 并执行给定条件的 shell 脚本,比如说 test.sh。如果只有 test.sh 的输入文件 wrapper.sh,我创建了一个包装脚本来调用 test.sh。
Wrapper.sh:

cd ${FILELOC    
COUNT=$(ls -l 1001_*.txt | wc -l)  

if [ "$COUNT" -ne 0 ]   
then      
/u/w/us/bin/test.sh.sh`       
fi

当我手动执行 wrapper.sh 时,会调用 test.sh 并在没有错误的情况下执行。但是当我在 cron 中安排它时,它会引发如下所示的错误

EXIT ERRORCODE;
 *** Exiting BTEQ...
 *** RC (return code) = 999

请帮助我理解问题

【问题讨论】:

  • 请检查脚本。第一行似乎缺少右括号,/u/w 行末尾有额外的反引号。还可以考虑添加 #! /bin/sh(或 bash)在 cron 中强制使用正确的 shell。
  • 在此处发布脚本时添加了反引号
  • #! /bin/sh 被添加到脚本中
  • 将'-x'添加到cron作业,并将输出重定向到文件(在脚本开头添加一行set -vx
  • 错误消息似乎不是来自 Terradata。 test.sh 脚本有什么作用?它是否取决于以交互方式设置但在 cron 下运行时未设置的 env var?

标签: linux shell unix error-code


【解决方案1】:
  • Shell 脚本名称似乎无效
  • 能否把test.sh.sh的内容分享一下,方便调试
  • 文件权限可能不正确。因此,它在从 cron 调度程序执行时失败了

【讨论】:

    猜你喜欢
    • 2012-04-06
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多