in my /etc/init.d/blabla script, which is the correct way to determine if the system is booting or the user root is runnig the script ?
I am thinking about * parent pid * euid * terminal... pts ?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
On traditional init (not systemd), your script would have
$0 as something like
Sxxblabla when run by init, where
xx are two digits.
When run by a user, there are usually a lot of environment variables set, like
HOME, and so on that are not set when running from init.
Note that in general, you want the effect of running the command in the shell and running the command at startup to be as identical as possible. Otherwise it may test fine from the command line but file when you boot.