Results 1 to 3 of 3
Can someone help me!
1. I am using CentOS 5.4 and I try to use inittab at the etc/inittab to initiate a program at startup
2. Below is my script ...
- 07-05-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 5
[SOLVED] Help inittab problem
Can someone help me!
1. I am using CentOS 5.4 and I try to use inittab at the etc/inittab to initiate a program at startup
2. Below is my script and saved as heritrix.sh
#!/bin/bash
export HERITRIX_HOME=/root/heritrix-1.14.3
cd $HERITRIX_HOME
chmod u+x $HERITRIX_HOME/bin/heritrix
$HERITRIX_HOME/bin/heritrix --admin=LOGIN:PASSWORD --port=9090
3. I did the chmod +x for the permission already.
4. I not confirmed whether it is running at startup.
5. the script is no problem as I have check it
- 07-05-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
That's not how you get a program to run at startup. You absolutely DO NOT want to modify /etc/inittab except to tell it what runlevel to boot into (id:N:initdefault
unless you REALLY know what you are doing, otherwise you may "brick" your system. There are a couple of ways to do what you want.
1. Add the initialization/termination of your application to /etc/rc.d/rc.local. That is the script the system uses to start/stop user-space services.
2. Add a script to each run-level (/etc/rc.d/rcN.d where N is the run-level) to start/stop the service.
Option one is the better one since the second one requires determining what run-levels you want to start your service at, and you have to decide where in the order of service startup/shutdown yours should go. Plus there may be other scripts or files you will have to deal with. Services that are specified in rc.local, they are started after all other services are started at boot and shutdown before other services are terminated when the system is shutdown/restarted. Here is the run-level 5 script for CUPS, the printer management system that is a good template for you to use:
I hope this helps.Code:#!/bin/sh # # "$Id: cups.sh,v 1.10 2000/03/30 05:19:16 mike Exp $" # # Startup/shutdown script for the Common UNIX Printing System (CUPS). # # Linux chkconfig stuff: # # chkconfig: 2345 56 10 # description: Startup/shutdown script for the Common UNIX \ # Printing System (CUPS). # # Copyright 1997-2000 by Easy Software Products, all rights reserved. # # These coded instructions, statements, and computer programs are the # property of Easy Software Products and are protected by Federal # copyright law. Distribution and use rights are outlined in the file # "LICENSE.txt" which should have been included with this file. If this # file is missing or damaged please contact Easy Software Products # at: # # Attn: CUPS Licensing Information # Easy Software Products # 44141 Airport View Drive, Suite 204 # Hollywood, Maryland 20636-3111 USA # # Voice: (301) 373-9603 # EMail: cups-info@cups.org # WWW: http://www.cups.org # # heavily edited so that it's more like other scripts in init.d on Red Hat # Linux # Source function library. . /etc/init.d/functions DAEMON=cupsd prog=cups start () { echo -n $"Starting $prog: " # start daemon daemon $DAEMON RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/cups return $RETVAL } stop () { # stop daemon echo -n $"Stopping $prog: " killproc $DAEMON RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/cups } restart() { stop start } case $1 in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -f /var/lock/subsys/cups ] && restart || : ;; reload) echo -n $"Reloading $prog: " killproc $DAEMON -HUP RETVAL=$? echo ;; status) status $DAEMON RETVAL=$? ;; restartlog) stop cat /dev/null >/var/log/cups/error_log start ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}" exit 3 esac exit $RETVALSometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-06-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 5
Thanks a lot. This really help me a lot.


