Я написал сценарий оболочки и поместил его в /etc/profile.d/.
Скрипт содержит следующее:
if [ ] # Boolean condition is in these brackets.
then
shutdown -P 23:00
Итак, когда я вхожу в систему, я получаю сообщение который начинается:
Error found when loading /etc/profile:
Shutdown scheduled for ... 23:00:00 PDT, use 'shutdown -c' to cancel.
As a result the session will not be configured correctly.
You should fix the problem as soon as feasible.
Это странно для меня, потому что я не внес никаких изменений в /etc/profile.
Мой вопрос из этого имеет несколько частей:
Я должен внести изменения в /etc/profile?
Или проблема, которую я использую shutdown в /etc/profile.d/?
В /etc/profile мы видим:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
То есть сценарии, называемые *.sh в /etc/profile.d, будут выполняться всякий раз, когда выполняется /etc/profile.
] Когда выполняется /etc/profile? man bash (или Online man page показывает:
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.
и:
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.
Все это означает, что каждый раз, когда вы вызываете /etc/profile (Выше показано, когда bash делает ли ваш ~/.bashrc?) сценарии будут запущены.
В ваших вторых (и последующих) вызовах /etc/profile, shutdown видит, что активен другой shutdown, и жалобы.
Вы могли бы поставить shutdown -c перед shutdown -P 23:00 в свой скрипт, чтобы заменить старый shutdown на новый shutdown.
В /etc/profile мы видим:
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
То есть сценарии, называемые *.sh в /etc/profile.d, будут выполняться всякий раз, когда выполняется /etc/profile.
] Когда выполняется /etc/profile? man bash (или Online man page показывает:
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.
и:
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.
Все это означает, что каждый раз, когда вы вызываете /etc/profile (Выше показано, когда bash делает ли ваш ~/.bashrc?) сценарии будут запущены.
В ваших вторых (и последующих) вызовах /etc/profile, shutdown видит, что активен другой shutdown, и жалобы.
Вы могли бы поставить shutdown -c перед shutdown -P 23:00 в свой скрипт, чтобы заменить старый shutdown на новый shutdown.