Where can I add to a $PATH so that it's available to all daemons? So that it's "included" or "sourced" before daemons start?
Many thanks!
Where can I add to a $PATH so that it's available to all daemons? So that it's "included" or "sourced" before daemons start?
Many thanks!
Daemons are started many different ways on different varieties of UNIX. Most of them have a way to setup the environment.
Perhaps the most fundamental is to set the environment for the init process, often through /etc/inittab. This will set the starting environment for all processes in the system.
If you have a script or a command, you could put it in /bin/ and set the appropiate owner and permisions using chmod and chown
I may have misread that, if you want to run something before daemons you could create a cron job or...
The system startup files are located in /etc/rc2.d. You can add a file to this directory with the commands you want to run at system startup. Suppose you want to delete some temp files at system startup, you could put a file named TempFileDel in your /etc/rc2.d with the commands to delete your temporary files, so it'll run every time system reboots. Helo. As shereenmotor says, usually, startup scripts are located in /etc/rc2.d, but this depends on the UNIX/Linux you run and your system's default run level. But I'm afraid it's not that easy. The script name must follow some rules: - There are two kind of scripts, let's say: kill scripts and start scripts. Both stored in /etc/rcX.d. - kill scripts are executed first, after that start scripts. - kill scripts name must start with a "K". - start sctipts name must start with a "S". - Following the first letter, there must be a two digit number. This lets "rc" know the order for the execution of the sctrips. rc is the "master" script which calls the others. Have a look at your /etc/inittab. - Finally, a name of your choice. when "rc" calls this scripts it adds a parameter: start for "S" scripts and stop for "K" scripts. This allows you to use the same script for both operations, just using links.
create a file
#!/bin/ksh
case $1 in
start)
echo Removing file...
rm /tmp/somefile;;
stop)
echo bye!;;
esac
and then
ln -s /path/to/TempFileDel /etc/rc2.d/S10TempFileDel
ln -s /path/to/TempFileDel /etc/rc2.d/K10TempFileDel