The first point is clear:/etc/profile is the configuration file that sets the environment variables for all users,/home/omm/.profile is the configuration file (omm User) that sets environment variables for a specific user .
But the important difference is: /etc/profile It's not always loaded. It wants to differentiate between login,non-login,interactive and non-interactive. mode of the case.
Loginlog in on behalf of the user, such as using"Su-"Command, or withSSHconnect to a server, will use the user's defaultShellStartLogin Shell mode. in this mode Shellwill go to automatic execution/etc/profileand the~/.profilefile.
no-login Shell Span style= "color: #1f497d; Font-family: The case of the song body is that we enter under terminal Span style= "color: #1f497d; font-family: Arial "> or Bash-c" CMD " Shell This mode is not automatically run any profile file.
Interactive Shell is interactive Shell, as the name implies is used to interact with the user , provides a command prompt to enter commands.
non-interactive Shell It is generally through bash-c "CMD" to execute. Bash .
SSH Login or sudo or Su-[USER] the commands are typical. Interactive Login Shell
but SSH server CMD Executing a command or executing a remote command through a program should theoretically be both a non-interactive non-login (non-interactive and non-logged) and it will not perform /etc/profile the.
Figure 1
Please refer to the information:
Https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Https://www.gnu.org/software/bash/manual/html_node/Interactive-Shells.html#Interactive-Shells
Https://wido.me/sunteya/understand-bashrc-and-profile
Http://www.cnblogs.com/qcly/p/3273373.html
Understanding the above scenario, it is more clear.
the memory problem is due to the call to the Curl command to cause. The order of invocation is as follows:
Curl, hdfs-service-check.sh, nodeagent-
because of controller ssh call start nodeagent by the previous description, it is a non-interactive non-login shell
will not be called to load /etc/profile This leads to the nodeagent no nss This environment variable, nodeagent call hdfs-service-check.sh ,
because the child process inherits the environment variables of the parent process, hdfs-service-check.sh also no NSS environment variables, so Curl command still exists
Memory issues.
so why would NSS variables are added to the /home/omm/.profile can you do that?
that's because Fusioninsight The file was loaded with the active explicit invocation.
from this call graph below, you can also see the start nodeagent explicitly loaded when the /home/omm/.profile File:
Figure 2
Interactive shell vs. non-interactive shell