Bash Shell 脚本在 /etc/profile.d 中每隔几纳秒执行 3 次

Bash Shell 脚本在 /etc/profile.d 中每隔几纳秒执行 3 次

大家好。。。遇到麻烦了,对某人来说是个开端。我把一个简单的 bash shell 脚本放入“/etc/profile.d”的根目录中,并且该脚本在纳秒内毫无差错地执行了 3 次。

为了诊断这个问题,在“/etc/profile.d”内使用以下语法创建了一个单独的 bash shell 脚本,所有三封电子邮件的结果都是相同的。

我可以在超过 15 台相同的 Oracle OEL 8.7 服务器上重现此异常。

出于所有显而易见的原因,我宁愿避免修改 /etc/profile 或 /etc/bashrc。

#!/bin/bash
loginctl show-session "$XDG_SESSION_ID" | mailx -r [email protected] -s "This is a development email" "[email protected]" 

结果:

Id=54
User=0
Name=root
Timestamp=Thu 2023-01-05 10:26:51 CST
TimestampMonotonic=613980645805
VTNr=0
TTY=pts/0
Remote=yes
RemoteHost=(IP address removed)
Service=sshd
Scope=session-54.scope
Leader=578034
Audit=54
Type=tty
Class=user
Active=yes
State=active
IdleHint=no
IdleSinceHint=1672936187092136
IdleSinceHintMonotonic=614156116099
LockedHint=no

括号内:

[ Oracle Linux Server 8.7 ]
[ Kernel: 5.15.0-5.76.5.1.el8uek.x86_64 ]

我已经考虑过一种锁,但是它们执行的时间相隔纳秒......

如有任何线索、建议或解决方案,我将不胜感激。

提前欢呼!

相关内容