Starting a service at startup.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Starting a service at startup.
# 1  
Old 05-11-2010
Starting a service at startup.

Hi guys I want to start a service and a script SiteMonitor.sh at startup.

Quote:
Here is brief working of SiteMonitor.sh
(This script monitors the ip addresses of machines which are using http service of the host.
This script checks this after every 5 seconds therefore i have run it at background.
)
To start with i have modified /etc/rc.local file.

Here is the content of my /etc/rc.local file.

Code:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/etc/init.d/oc4j start
/usr/local/sbin/SiteMonitor.sh &
service httpd start

My problem is after i restart the machine only SiteMonitor.sh script get
executed but the command service httpd start doesnt .Therefore i have to manually login to the system and fire service httpd start to start apache.

I would also like to know whether the script SiteMonitor.sh is running or not?
How would i do that?
# 2  
Old 05-11-2010
Maybe inittab or appropriate entries/links etc. in /etc/init.d/rc.d is an alternative for you. What OS is this?
# 3  
Old 05-11-2010
Quote:
Originally Posted by zaxxon
Maybe inittab or appropriate entries/links etc. in /etc/init.d/rc.d is an alternative for you. What OS is this?
What is the disadvantage in putting the entries in /etc/rc.local?
My Linux distribution is
Code:
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description:    Enterprise Linux Enterprise Linux Server release 5.2 (Carthage)
Release:        5.2
Codename:       Carthage

# 4  
Old 05-11-2010
I see no disadvantage, just wanted to show possible alternatives. If your script does not come back after starting /usr/local/sbin/SiteMonitor.sh &
, you might try to add a nohup in front of it. To know if it is running or not, you will maybe want to have a separate mechanism to check, depending if you want to check it continously or only after that initial launch.
For only initial checking after the start, you could grep for a process and check it's $?, or rely on a lock/pid file (or both) you might have placed.
This User Gave Thanks to zaxxon For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Rpcbind service not starting

Hello all, I have read just about every rpcbind not starting thread and article on the internet it seems, but I have not found a solution to my problem as of yet. I have a solaris 10 server that has been running with no problems for a while. The other day it crashed and would not boot to the gui... (2 Replies)
Discussion started by: Madrox72
2 Replies

2. Red Hat

Start a service manager process automatically on startup

Hello, I am in the process of learning Linux OS. How do I run the below lines of code automatically as root on server startup. cd /opt/program_folder/ServiceManager/bin nohup ./servce_manager DEV & Currently, as soon as the server is up and running I log in as root (as this... (6 Replies)
Discussion started by: rparavastu
6 Replies

3. Solaris

run a service via startup script (correct me if I am wrong)

Environment Solaris 9 I have configured the Solaris9 as NTP client in which Solaris9 is syncing the time with a windows2008 R2 Server which is runing fine. Now I want that the xntpd service should start at startup. I did this via a script. Kindly correct if I did any thing wrong: 1.)Made... (9 Replies)
Discussion started by: z_haseeb
9 Replies

4. Solaris

StartUP file to start a service

Hi guys: i have a Solaris 10 development server and a Solaris 9 production server. The entire task must be done in the dev. server. When it's done and all the testing is OK, the script or files are transfer to prod. Server. All right. Now I have to figure out a way to put a script to initiate... (2 Replies)
Discussion started by: bmathiasf
2 Replies

5. AIX

service/process management -autostart at startup

Hi, I want to modify some of the services/processes (related to the oracle database) to start automatically at the startup of the server. which commands may help me? which commands do I need to use? my server configuration is, in brief: hardware:IBM P550 / OS : AIX 5300 thanks,... (1 Reply)
Discussion started by: talipk
1 Replies

6. AIX

Creating startup service for JBoss

Hello Friends, Does anyone know how to create a startup script for Jboss on IBM AIX 5.3? Please help me, I'd be highly grateful to you... Thanks & Regards, Vinit (0 Replies)
Discussion started by: vpatil6688
0 Replies

7. AIX

Service starting Problem

Dear All, When i am start the service netd i am facing the problem 0513-015 The inetd Subsystem could not be started Please check subsystem resources and try again later. please suggest me. It is urgent (1 Reply)
Discussion started by: pernasivam
1 Replies

8. UNIX for Advanced & Expert Users

AIX 5.3: Start Service on System startup

Hi, I'm new to AIX, and have to make some services start at system startup. The IBM-Redbook says I have to edit /etc/inittab. As a long time (Debian)-Linux Admin I'm a bit confused. Is there something like /etc/init.d/$SERVICE in AIX? Greetings, Dennis (1 Reply)
Discussion started by: dennis.kuehl
1 Replies

9. UNIX for Dummies Questions & Answers

starting jabber server on startup

Fedora Core2 Jabberd 1.4.2 quickstart Anyone using a jabber server? Do you know how to have it startup when booting? I can't seem to figure that part out. Jeff (1 Reply)
Discussion started by: lawadm1
1 Replies

10. UNIX for Dummies Questions & Answers

How can I add my own service when system startup?

Hi All, My OS is redhat 7.1. How can I start my own service (e.g. simple scripts) when the system is started? I found something like /etc/rc.d, /etc/rc.init ... But I have no idea on them, have anyone can help me? regards wilson (6 Replies)
Discussion started by: wilsonchan1000
6 Replies
Login or Register to Ask a Question