The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to start/stop cron jobs on live server varaprasadu SUN Solaris 2 03-12-2008 10:09 PM
system won't start to GUI it stuck eykyn17 SUN Solaris 7 11-14-2007 01:19 PM
cron does not start the need job Anta UNIX for Advanced & Expert Users 5 07-10-2006 06:50 AM
System will not start karlb1 SCO 1 11-04-2004 07:48 AM
how to start the x window system nobody HP-UX 7 04-09-2004 04:55 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-05-2006
Registered User
 

Join Date: Jun 2006
Posts: 24
Cron job at system start up

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.
Reply With Quote
Forum Sponsor
  #2  
Old 07-05-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
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
Reply With Quote
  #3  
Old 07-06-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
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:
Code:
#!/bin/ksh
case $1 in
start)
   echo Removing file...
   rm /tmp/somefile;;
stop)
   echo bye!;;
esac
and then:
Code:
ln -s /path/to/TempFileDel /etc/rc2.d/S10TempFileDel
ln -s /path/to/TempFileDel /etc/rc2.d/K10TempFileDel

Regards.
Reply With Quote
  #4  
Old 07-06-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
Thanks grial, for refining my concepts about UNIX boot process. rgrds, Tayyab
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0