【发布时间】:2014-02-21 03:01:31
【问题描述】:
/etc/profile 中声明的环境变量:
export MYNAME=rhel
从 monit 运行的脚本内容是 [/tmp/printmyname.sh]:
echo "My Name is: "$MYNAME >> /var/log/env_variablefile.out
监控内容:
check file PrintVariable with path /var/log/something.out
start program = "/bin/sh /tmp/printmyname.sh"
if timestamp > 1 minutes then start
当/var/log/something.out 文件一分钟后没有更新时,我想打印在/etc/profile 中声明的环境变量到/var/log/env_variablefile.out。
所以我的问题是,当我直接运行 /tmp/printmyname.sh 时,它会将 My Name is: rhel 附加到 /var/log/env_variablefile.out 中,但是当它从 monit 运行时,它只会打印 My Name is:。
所以我想知道这种行为的原因和解决问题的方法。
注意:monit 每 10 秒运行一次,以上代码只是我实际代码的示例。
【问题讨论】: