Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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.

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 1esac
exit 0
*********************************************

![]() |
![]() |
![]() |

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