Olhando para /etc/profile
, vemos:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
Ou seja, os scripts chamados *.sh
in /etc/profile.d
serão executados sempre que /etc/profile
for executado.
Quando /etc/profile
é executado? man bash
(ou Página man online mostra:
When bash is invoked as an interactive login shell, or as a non-
interactive shell with the --login option, it first reads and executes
commands from the file /etc/profile, if that file exists. After
reading that file, it looks for ~/.bash_profile, ~/.bash_login, and
~/.profile, in that order, and reads and executes commands from the
first one that exists and is readable. The --noprofile option may be
used when the shell is started to inhibit this behavior.
e:
If bash is invoked with the name sh, it tries to mimic the startup
behavior of historical versions of sh as closely as possible, while
conforming to the POSIX standard as well. When invoked as an
interactive login shell, or a non-interactive shell with the --login
option, it first attempts to read and execute commands from
/etc/profile and ~/.profile, in that order. The --noprofile option may
be used to inhibit this behavior.
Tudo isso significa que toda vez que você invocar /etc/profile
(O acima mostra quando bash
faz isso, o seu ~/.bashrc
?) os scripts serão executados.
Na sua segunda (e subsequente) invocação de /etc/profile
, shutdown
vê que outro shutdown
está ativo e reclama.
Você pode colocar shutdown -c
antes de shutdown -P 23:00
em seu script para substituir o antigo shutdown
pelo novo shutdown
.