Reputation: 3404
I have a init script on FreeBSD. This script called on startup by rc.d. What I want to do that to check if this script called on start up or manually by user. How can I do this check in this script. Is it possible? Thank you for any help...
Note that my question is valid for FreeBSD but I also added linux tag in case of maybe same solution may be aplied for linux
Upvotes: 0
Views: 3224
Reputation: 3069
Startup scripts are executed by /etc/rc
during system boot.
I believe there is no standard way to do what you want to achieve.
You would need to modify /etc/rc
and set (and export) some kind of environment variable, whose presence you could test in your own scripts.
The situation on Linux is different in that there is no common approach. Startup scripts/scenarios depend on the distribution used.
Upvotes: 1
Reputation: 1621
you can check whether your desired process is running or not using "ps" command:
e.g:
ps -A | grep "process name"
It gives the desired process name with the process id.
Upvotes: 0
Reputation: 5447
I've not tested this, but you can try to first get PID of parent process, and then check owner.
ps --no-header -o user $PPID
Upvotes: 0