I want to know if there is a way to make a certain set of programs start in order at system startup with cron or something else i dont know about.
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.
Regards,
Tayyab
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.
Well, the UNIX boot process is a little bit more complicated, but for now that's enough.
In your case, you could create a scritp called TempFileDel (contuinuing with shreenmotor's example) which supports "start" and "stop" operations/parameters. For instance:
#!/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
Regards.
Thanks grial, for refining my concepts about UNIX boot process. rgrds, Tayyab