Score:0

Bash Shell Script Executing 3 Times in /etc/profile.d within Nanoseconds apart

ng flag

g'day all.. in a spot of bother and a starter of ten for someone. I have placed a simple bash shell script into the root of "/etc/profile.d" and without fail, the script executes 3 times within nanoseconds.

To diagnosis this, made a separate bash shell script within "/etc/profile.d" with the following syntax below, and all three email results are identical.

I can reproduce this anomaly on over 15 identical Oracle OEL 8.7 servers.

I would prefer to avoid modifying /etc/profile or /etc/bashrc for all the obvious reasons.

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

Results:

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

Parenthetical:

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

I have entertained a species of lock, however these are executed nanoseconds apart...

I would be massively grateful for any clues, suggestions or solutions.

Cheers in advance!

user999317 avatar
ng flag
Terribly sorry... Failed to mention that the script is designed to execute when logging into GDM. After successfully logging in, the script executes 3 times. However, when I launch a terminal session, the script executes just the once.
diya avatar
la flag
I wouldn’t be surprised that, when logging into GDM , several processes and or shell scripts get started, some of which run with a full shell environment (rather than fully stand alone) and thus sourcing content from profile.d
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.