巡检时发现一个cron作业在跑shell脚本时,shell脚本的日志文件中会有下面这个信息: stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
[info ]: 20250319 13:45:01> ----------------- the monitor_alert_log.sh start ------------------
[info ]: 20250319 13:45:01> ----------------- the monitor_alert_log.sh start ------------------
[info ]: 20250319 13:45:01> there is no new error logs and warning logs are generated
[info ]: 20250319 13:45:01> there is no new error logs and warning logs are generated
[info ]: 20250319 13:45:01> ----------------- the monitor_alert_log.sh stoped -----------------
[info ]: 20250319 13:45:01> ----------------- the monitor_alert_log.sh stoped -----------------
有点奇怪,这个脚本经过不停的打磨完善,我对它可以说熟悉得不能再熟悉了,不应该报这样一个"诡异"的告警,带着疑惑跟踪脚本发现,问题在于脚本中会执行下面环境变量文件。
if [ -f ~/.bash_profile ];
then
. ~/.bash_profile
# source ~/.bash_profile
fi
而.bash_profile中设置了stty。如下所示:
$ grep stty ~/.bash_profile
stty erase ^H
这个是同事设置的,设置原因:设置后可以在sqlplus中使用backspace键删除错误输入,否则只能使用ctrl+backspace删除错误输入。其实网上已经有人遇到并总结过这个案例。注释掉上面这个设置后,shell脚本运行就不会有这个告警(信息)输出了。
参考资料:
https://blog.itpub.net/28602568/viewspace-2092004/
文章转载自DBA闲思杂想录,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




