Computing.Net > Forums > Linux > Start program on startup

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Start program on startup

Reply to Message Icon

Name: Adam
Date: September 5, 2002 at 23:11:30 Pacific
OS: Redhat 7.3
CPU/Ram: N/A
Comment:

I've just finished writing a perl pop3 email client program which executes system commands based on emails recieved (for instance start and stop apache, etc...) and now i would like to know how i can start it automatically upon system startup... it would have to run in the background as a service i suppose..

Thanks,
Adam



Sponsored Link
Ads by Google

Response Number 1
Name: 3Dave
Date: September 6, 2002 at 03:18:35 Pacific
Reply:

Ideally you want to write a little "rc" script for it so that you can start|stop|restart the service, dump the script into /etc/init.d, then put links to it in /etc/init.d/rcX.d (where X is the runlevel you want the service to be available)

NB follow the naming convention of SXX and KXX (the higher the numbers, the later the service is started/killed)


Alternatively, just add it to your rc.local script, but you wouldn't have as much control over the service.


0

Response Number 2
Name: Adam
Date: September 6, 2002 at 10:31:54 Pacific
Reply:

I wrote the following simple script for it and added the link to rc3.d/S57docmd to start it after inetd and the others..
However, on system startup it *says* it was ok but in reality it doesnt startup on bootup. However, after i log on if i do "service docmd start" it starts up fine..
Also, this program is meant to be run neverending in the system background to be able to execute commands remotely from.. would the most effecient way of doing this be on the program level by a neverending system loop with a sleep between each one for x seconds or would it be setting it up as a cron job to execute every x seconds?

Thanks,
Adam

*********************************************
#!/bin/sh
# Startup script for docmd

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /home/Hammouda/docmd ] || exit 0

prog="docmd"

start() {
echo -n $"Starting $prog: "
/home/Hammouda/docmd
echo
}

stop() {
echo -n $"Stopping $prog: "
killproc docmd.pl
echo
}

case "$1" in
start)
start
;;

stop)
stop
;;

status)
status docmd
;;
restart)
stop
start
;;

*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1

esac

exit 0
*********************************************


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Start program on startup

Start Samba on startup www.computing.net/answers/linux/start-samba-on-startup/23163.html

Start services on start up www.computing.net/answers/linux/start-services-on-start-up/9985.html

Run a program on remote site www.computing.net/answers/linux/run-a-program-on-remote-site-/7826.html