2017-10-05 355 views
0

我正尝试使用unix AIX中的sendmail实用程序发送电子邮件。当无法从crontab捕获文件 - cat:0652-050 ​​ - unix AIX

mailheader:

To: [email protected] 
From: [email protected] 
MIME-Version: 1.0 
Content-Type: text/html; charset=us-ascii 
Subject: Alert 

status.hmtl - >包含HTML报告使用DB查询

(cat ./mailheader ./status.html) | sendmail -t

当我尝试从一个shell脚本中使用上面的命令后台crontab标签我在日志中得到以下消息:

cat:0652-050无法打开./mailheader。 cat:0652-050无法打开./status.html。

但是,当我手动运行它时,shell脚本运行完美。

请让我知道你的想法

+0

是否将您的'cron'脚本chdir放入相应的目录? –

+0

显然我错过了这一个。现在已经解决了。谢谢 – Sathya

回答

0

使用绝对路径,像

(cat /there/mailheader /there/status.html) | sendmail -t 

或者使用cd

cd /somepath 
(cat mailheader status.html) | sendmail -t 

但首先,调试。将这些行添加到脚本中:

set -xv 
exec >>/tmp/debug.$$ 2>&1 
date 
pwd 
id -a 
env 
1

我没有从crontab更改目录,因此我得到了错误信息。

使用绝对路径和调试来找出问题,并在我的脚本开始时添加cd来解决问题。