You can start it via rc.local if you like (more BSD style). Just add /path/to/snmpd && echo "SNMP Started! ".
Hi, I have been trying to bring up snmpd automatically without luck. I would appreciate if anyone could point out what I did wrong. What I did:
(1). Put the following script (named snmp) in /etc/init.d:
#!/bin/sh
test -x /usr/local/sbin/snmpd || exit 0
SNMPDPID=/var/run/snmpd.pid
case "$1" in
* * *start)
* * * * * *echo -n "Starting SNMP server: snmp"
* * * * * *sleep 30
* * * * * *start-stop-daemon --start --quiet --pidfile $SNMPDPID \
* * * * * * * * *--exec /usr/local/sbin/snmpd
* * * * * *echo "."
* * * * * *;;
* * *stop)
* * * * * *echo -n "Stopping SNMP server: snmp"
* * * * * *start-stop-daemon --stop --quiet --pidfile $SNMPDPID
* * * * * *echo "."
* * * * * *;;
* * *restart | force-reload)
* * * * * *echo -n "Stopping SNMP server: snmp"
* * * * * *start-stop-daemon --stop --quiet --pidfile $SNMPDPID
* * * * * *echo "."
* * * * * *sleep 2
* * * * * *echo -n "Starting SNMP server: snmp"
* * * * * *start-stop-daemon --start --quiet --pidfile $SNMPDPID \
* * * * * * * * *--exec /usr/local/sbin/snmpd
* * * * * *echo "."
* * * * * *;;
* * **)
* * * * * *echo "Usage: /etc/init.d/snmp {start|stop|restart|force-reload}"
* * * * * *exit 1
esac
exit 0
(2). Make a symlink: /etc/rc3.d/S99snmp -> ../init.d/snmp
(3). After log on as root, do "init 3"
My snmpd makes call to another program, and I do see printf message from that program. However, I don't see printf message from snmpd itself. "ps -ef | grep snmpd" doesn't show snmpd running.
If I run "/etc/init.d/snmp start" at command line, snmpd does get started and function normally.
By the way, "sleep 30" in snmp script is to make sure the other program comes up and running before starting snmpd. I made sure 30 seconds is enough for that. The other program is also auto-start (successfully, with /etc/rc3.d/S98...).
Thanks for your attention.
You can start it via rc.local if you like (more BSD style). Just add /path/to/snmpd && echo "SNMP Started! ".
Hi, Ashcrow:
Thanks for your reply. I am new to Linux so I have the following questions:
1. Should rc.local be in /etc?
2. How to run what's in rc.local?
3. My snmpd has to wait until another process comes up correctly. This process is started at running level 3 (by "init 3". Is it possible to tell rc.local not to start until all processes in rc3.d are started?
I appreciate your time.
You can start it via rc.local if you like (more BSD style). Just add /path/to/snmpd && echo "SNMP Started! ".
Well, you didn't say what distro you use.1. Should rc.local be in /etc?
In my Red Hat, the rc.local file is in /etc. In my Debian (Woody), they use rcS.d with individual scripts in there.
So if it's rc.local, then you type in what Ashcrow said to that file and it should start up at boot time.2. How to run what's in rc.local?
Then you should run your script in rc3.d after the other process is done initiating.3. My snmpd has to wait until another process comes up correctly. This process is started at running level 3 (by "init 3".
Nope. rc.local start before it enter into the run levels. rc.local is what started up when your system boot up. Many distros avoid to use rc.local lately unless absolutely need to. Starting from run levels is easier to manage since all you need is delete or rename files for that service and you are done instead of looking for that script area and modifying/commenting.Is it possible to tell rc.local not to start until all processes in rc3.d are started?
Well, in RedHat, MAndrake, and SuSE the service/daemon scripts are all in the rcX.d directory. Each script is going to be a SYYservicename or KYYservicename. The S and K is for start and kill, and the YY is the number following it denoting the order in which to startup/kill that service.Make a S and K script and plop it in each runlevel you want. That is denoted by the rcX.d directory, in which X is the runlevel.
HTH
Thanks for all your replies. I use Debian. I setup correctly for snmp to start in rc3.d. My problem is, when I run "init 3", snmpd tries to start but doesn't stay up. However, if I run snmp startup script manully at command line prompt, snmpd starts and stays up. Could anyone tell me what's the difference between these two ways to bring up the daemon?
Bookmarks