The venerable old-skool Splunk forums are now closed. Feel free to search for old content here, but new posts are no longer supported.

Instead, please visit the thriving community at answers.splunk.com to ask and answer questions about your Splunk deployment and how to get the most out of it.

Forums: SplunkGeneral: Start/Stop splunk under RedHat

Previous Topic: FifoLoader Not Available  |   Next Topic: Centralizing syslog on Solaris


Posts 1–6 of 6

HI all,

Does somebody has a start/stop script to be able to start splunk as a daemon at reboot/shutdown of the RedHat linux server.

Thanks.
Pierre.

Hi Pierre,

The method that I've always used is to make a copy of another init script in /etc/init.d and modify it to start the program. It's best to pick one of the more simple startup scripts. It's been a little while since I've done such things, but I used to always use the Samba one as my template.

I'll see if I can put together a quick one that will work across linux platforms. Keep an eye on this forum and I'll post a link to it here.

Joe

Pierre,

As Promised, here's a start script for you:
http://mysfitt.net/projects/splunkcode/splunk-init

Just place it in your /etc/init.d directory and set up the necessary sys-v style symlinks under the rc runlevel that you want splunk to start in. If you've never done that by hand, just ask and I'll tell you how to set it up.

By the way, this script should work for any Linux distro, not just redhat. I wrote it in such a way that it uses LSB init functions if they exist and failing that, I've included enough LSB functions out of the library to make it work without assuming anything about the system. So this should be a "universal" splunk init script.

I'll add an entry to my splunk faq about this as well since it seems like it'd be a good topic to cover.

cheers,
Joe

Pierre,

found a redhat bug in the first version. I assumed that redhat supported LSB 2.0 and I was wrong about that...

I've enabled a workaround for redhat based distros so it should work for everybody now. Now that I've said that, prove me wrong :-)

you can grab the fixed version from the same place:
http://mysfitt.net/projects/splunkcode/splunk-init

cheers,
Joe

<p>
[Modified by: Joe Reeves (Joseph Reeves) on May 09, 2006 06:15 PM]</p>

Joe,

Thanks for your script. I have also read the post of Paul Krizak concerning the /var/lock/subsys. It's used I think to prevent splunk to start two times. To add this feature in the splunk script, I have added the following :

RETVAL=0

start)
log_begin_msg "Starting Splunk..."
/opt/splunk/bin/splunk start > /dev/null 2>&1
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk
log_end_msg $RETVAL
;;

stop)
log_begin_msg "Stopping Splunk..."
/opt/splunk/bin/splunk stop > /dev/null 2>&1
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/splunk
log_end_msg $RETVAL
;;

Add the service :
[root@linprd03 init.d]# chkconfig --add splunk
[root@linprd03 init.d]# chkconfig --list splunk
splunk 0:off 1:off 2:off 3:on 4:on 5:on 6:off

I hope it's ok. I have tested it and it works.
Perhaps somebody can confirm it.

Thanks.
Regards.
Pierre.

Pierre,

Thanks for your patch! The only addition I see necessary is to check for the existance of /var/lock/subsys before trying to touch a file there. I'll integrate your enhancement and post here when the new version is available.

Thanks again!
Joe