Configure Splunk Enterprise to start at boot time

On most operating systems, you can configure Splunk software to start running automatically after the machine and operating system boots. This reduces interruption of both sending and receiving data. All on-premises versions of Splunk software can be configure this way. On *nix platforms, you must manually configure the software to start at boot time after you install it.

You can configure the software as either the root user, or as a regular user with the sudo command. Nearly all distributions include sudo but if yours does not have it, you should consult the help for your distribution to download, install, and configure it.

Enable boot-start on the Windows platform

On Windows, the installer configures Splunk software to start at machine startup. To disable this, see Disable boot-start on Windows at the end of this topic.

Enable boot-start on *nix platforms

Splunk provides a utility that updates your system boot configuration so that the software starts when the system boots up. This utility creates an init script (or makes a similar configuration change, depending on your OS).

Log into the machine that you have installed Splunk software on and that you want to configure to run at boot time.

Become the root user if able. Otherwise, you must run the following commands with the sudo utility.

Run the following command:

[sudo] $SPLUNK_HOME/bin/splunk enable boot-start

Enable boot-start as a non-root user

If you do not run Splunk software as the root user, you can pass in the -user parameter to specify the Splunk software user. The user that you want to run Splunk software as must already exist. If it does not, then create the user prior to running this procedure.

The following procedure configures Splunk software to start at boot time as the user 'bob'. You can substitute 'bob' with the user that Splunk software should use to start at boot time on the local machine.

Log into the machine.

Become the root user.

Run the following command:

[sudo] $SPLUNK_HOME/bin/splunk enable boot-start -user bob

Change the ownership of the Splunk installation directory and all its files to user bob:

Enable boot-start on MacOS

Splunk software automatically creates a script and configuration file in the directory /System/Library/StartupItems on the volume that booted your Mac. This script runs when your Mac starts, and automatically stops Splunk when you shut down your Mac.

If you want, you can still enable boot-start manually. You must either have root level permissions or use sudo to run the following command. You must have at least administrator access to your Mac to use sudo. If you installed Splunk software in a different directory, replace the example below with your instance location.

Comments

If you're using CentOS 7 or another systemd linux, you might want to setup a systemd unit file instead of using the old init.d file. There's a good post on it here: https://answers.splunk.com/answers/59662/is-there-a-systemd-unit-file-for-splunk.html

Flakshack

June 14, 2018

For *unix, there is a statement
Confirm that each splunk command has single quotes around it.

This is not applicable to Redhat.

Htidore

May 25, 2018

Hi Rg33,

Thanks for your feedback. The splunkd binary places it in /Library/LaunchAgents, and to change it to /Library/LaunchDaemons would require making code modifications. Theoretically, you could move it over to /Library/LaunchDaemons yourself, but if you later disable boot-start, it could cause errors to occur because it will attempt to make changes to the plist file in /Library/LaunchAgents.

Malmoore, Splunker

March 26, 2018

For MacOS, would it be better to have "splunk enable boot-start" place the "com.splunk.plist" file in /Library/LaunchDaemons to start at boot, instead of /Library/LaunchAgents which runs on login?

Rg33

March 24, 2018

I updated the example to use the actual user rather than the substitute variable. It should be clearer now that you must substitute the user that Splunk runs as in the file.

Malmoore, Splunker

November 8, 2017

Hi,

looks like it's not clear for everybody, you need to replace the user variable when doing the real change to init script and the simple quote is at the end (because it close the argument to su -c 'command')
so that would become 4 changes with the current init script (if splunk run as splunk user and installed in /opt/splunk)
su - splunk -c '"/opt/splunk/bin/splunk" start --no-prompt --answer-yes'
su - splunk -c '"/opt/splunk/bin/splunk" stop'
su - splunk -c '"/opt/splunk/bin/splunk" restart'
su - splunk -c '"/opt/splunk/bin/splunk" status'

Maraman splunk, Splunker

November 8, 2017

Hi Archme,

I will follow up with our engineers to determine why that command doesn't work. I tested it myself on CentOS 7 and macOS Sierra and it worked. I'll advise you on my findings in email.

Thanks for the report!

Malmoore, Splunker

October 27, 2017

Under "Enable boot-start as a non-root user", item #6, the following command does not work for me:
su - ${USER} -c '"<path to Splunk installation>/bin/splunk"'
It is mentioned under the command: The Splunk command has both single and double quotes around it. Confirm that the quotes are in the correct order.

The command that i used in the file was: su - ${USER} -c '"/opt/splunk/bin/splunk start --no-prompt --answer-yes"'

it gave me the following error when starting:
su: unrecognized option '--no-prompt'

The command that worked for me was:
su - ${USER} -c '/opt/splunk/bin/splunk start --no-prompt --answer-yes'
Note that I only used single quote.

In the instructions above, under "Boot-start script does not inherit user limits set at boot time", point 4 is incorrect. The modification needs to happen in the splunk_start() function on line 16. No reboot is required, simply "splunk stop" and then "splunk start" will pick up the change and ulimits will be respected.

Tested on RHEL 7.3 and Splunk 6.6.2

Jamesarmitage

July 29, 2017

Hi Fairje,

Thanks for the report. We're investigating this now. We were asked to add this section because Splunk was not inheriting the correct user limits for non-root users at boot time. We'll make adjustments as necessary after we complete the investigation.

Malmoore, Splunker

May 25, 2017

Section: Boot-start script does not inherit user limits set at boot time
This no longer appears to be applicable and in-fact will mess up your boot up sequence. Upon running this script after you put in this change it tries to drop your into a terminal under that user and the script just stalls out, which in turn stalls out your boot up sequence. It would appear that removing this (or not putting it in in the first place) causes Splunk to be started correctly under the right splunk user context.

This was done on RHEL 6.8 and Splunk 6.4.6. It is unclear when this specifically changed and if it was a linux change or splunk change or both?

Enter your email address, and someone from the documentation team will respond to you:

Send me a copy of this feedback

Please provide your comments here. Ask a question or make a suggestion.

Feedback submitted, thanks!

You must be logged into splunk.com in order to post comments.
Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic.
If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk,
consider posting a question to Splunkbase Answers.

0
out of 1000 Characters

Your Comment Has Been Posted Above

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website.
Learn more (including how to update your settings) here »