Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-21-2002, 04:57 PM   #1
LQ Newbie
Registered: Jun 2002
Posts: 6

Rep: Reputation: 0
Question Using cron to start a program at reboot ?

I have a program that I want to run as a service on my linux machine i.e. it should always be executing. After a system reboot it should start running automatically without any user intervention.

I was thinking of using cron to somehow schedule the program to launch after every reboot but I am not sure if that what I should be using.

Are there any other methods to convert existing programs into programs that get launched automatically at boot time ? I read something about daemons but do not know much about them or how to programs them.

Any suggestions or pointers will be of great help.

Thanks !!
Old 06-21-2002, 06:34 PM   #2
Registered: Jan 2002
Distribution: Debian Based only but have tried most others.
Posts: 82

Rep: Reputation: 15
No that is not what your should be doing.

Linux already has built in run level's to allow to have programs start at different times. (Runlevels are like safemode for windows)
For example run level3 is normal mode why level1 is safe mode. Now if your running X windows then level 5 is normal mode.

Now depending on what flavor of linux you have you can either be using the system V init or the free bsd type.

Assuming that its a system V start up you will look in your etc directory and notice the
Look in that directory and you will notice a bunch of startup scripts these are the scripts that are used to start the proccess at different run levels.

Now look back in etc and look for directorys that start with rc
If you look those directories you will find symbolic links to the init.d directory I showed you ealier. Depending on what runlevel you are starting (3 for consol only and 5 for xwindows) by using the name convention it will tell you what process's start and what ones should be killed.
so a symbolic link called S80httpd
means start your web service (apache in my case) after all other scripts with lower number than 80.

Get it and K would mean kill that service, and thats used if you switch from one runlevel to another. So if your going from runlevel 3 to 1 it will kill all the proccess's then go to one.

YOu can switch runlevels by typeing init "runlevelwanted".

Before I go into more detail here is a good link you can check out and come back if you need more help

One thing you will have to understand is the scripts are written in a certain way so linux can understand how to use them. You can modify there runlevels by hand or by a the chkconfig command. If this is a homade script this may not work perfectly and you may want to look into the rc.d file that will run after all the other runlevel process's.


Last edited by Road; 06-21-2002 at 06:39 PM.
1 members found this post helpful.
Old 06-22-2002, 05:31 PM   #3
LQ Newbie
Registered: Jun 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Thumbs up

Thanks for such a good explanation. I understood the concept completely.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot start cron; FIFO exists deverest Solaris / OpenSolaris 17 04-14-2008 10:55 AM
How do I start graphical applications via cron? p0ser Linux - Software 7 01-21-2005 03:44 PM
cron reboot problem tcpdump Linux - Software 3 05-14-2004 07:05 AM
Cron Reboot Virtus Linux - Software 3 01-13-2003 08:42 AM
X won't start after reboot kodiakmook Linux - General 3 12-21-2001 04:25 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration