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:
[sudo] chown -R bob $SPLUNK_HOME
- Using a text editor, open
/etc/init.d/splunk
for editing. - Make the following changes as shown in the "After" table:
Before RETVAL=0 . /etc/init.d/functions splunk_start() { echo Starting Splunk... "$SPLUNK_HOME/bin/splunk" start --no-prompt --answer-yes RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk } splunk_stop() { echo Stopping Splunk... "$SPLUNK_HOME/bin/splunk" stop RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/splunk } splunk_restart() { echo Restarting Splunk... "$SPLUNK_HOME/bin/splunk" restart RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk } splunk_status() { echo Splunk status: "$SPLUNK_HOME/bin/splunk" status RETVAL=$? } case "$1" in
After RETVAL=0 USER=bob . /etc/init.d/functions splunk_start() { echo Starting Splunk... su - ${USER} -c '"$SPLUNK_HOME/bin/splunk" start --no-prompt --answer-yes' RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk } splunk_stop() { echo Stopping Splunk... su - ${USER} -c '"$SPLUNK_HOME/bin/splunk" stop' RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/splunk } splunk_restart() { echo Restarting Splunk... su - ${USER} -c '"$SPLUNK_HOME/bin/splunk" restart' RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk } splunk_status() { echo Splunk status: su - ${USER} -c '"$SPLUNK_HOME/bin/splunk" status' RETVAL=$? } case "$1" in
Confirm that each
splunk
command has single quotes around it. - Save the file and close it.
Changes take effect the next time you boot the machine.
Enable boot-start on machines that run systemd
On Linux machines that use the systemd
system manager, you can configure Splunk Enterprise to let systemd
control it. By default, Splunk Enterprise configures itself to run as a systemd
-managed service.
- 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 -systemd-managed 1
See Run Splunk Enterprise as a systemd service for additional information on Splunk Enterprise and systemd
.
Enable boot-start on machines that run AIX
These instructions work for both Splunk Enterprise and the AIX version of the Splunk universal forwarder. Splunk does not offer a version of Splunk Enterprise for AIX for versions later than 6.3.0.
The AIX version of Splunk does not register itself to auto-start on machine boot. You can configure it to use the System Resource Controller (SRC) to handle boot-time startup.
When you enable boot start on an AIX system, Splunk software interacts with the AIX SRC to enable automatic starting and stopping of Splunk services.
mkssys -G splunk -s splunkd -p <path to splunkd> -u <splunk user> -a _internal_exec_splunkd -S -n 2 -f 9
mkssys -G splunk -s splunkweb -p <path to python> -u <splunk user> -a _internal_exec_splunkweb -S -n 15 -f 9
(on Splunk Enterprise only)
When you enable automatic boot start, the SRC handles the run state of the Splunk Enterprise service. You must use a different command to start and stop Splunk software manually.
/usr/bin/startsrc -s splunkd
to start Splunk software manually./usr/bin/stopsrc -s splunkd
to stop Splunk software manually.
If you try to start and stop the software with the ./splunk [start|stop]
method from the $SPLUNK_HOME
directory, the SRC catches the attempt and displays the following message:
Splunk boot-start is enabled. Please use /usr/bin/[startsrc|stopsrc] -s splunkd to [start|stop] Splunk.
To prevent this message from occurring and restore the ability to start and stop Splunk Enterprise from the $SPLUNK_HOME
directory, disable boot start:
[sudo] ./splunk disable boot-start
- For more information on the
mkssys
command line arguments, see Mkssys command on the IBM pSeries and AIX Information Center website. - For more information on the SRC, see System resource controller on the IBM Knowledge Center website.
Enable boot-start on AIX to run Splunk Software as a root user
- Log into the AIX machine.
- Become the root user, if able. Otherwise, you must prepend
sudo
to the following command examples. If you do not havesudo
on your AIX instance, you must download, install, and configure it. - Change to the Splunk bin directory.
- Enable boot start:
[sudo] ./splunk enable boot-start
Enable boot-start on AIX to run Splunk software as a non-root user
- Log into the AIX machine.
- Become the root user, if able. Otherwise, you must prepend
sudo
to the following command examples. If you do not havesudo
on your AIX instance, you must download, install, and configure it. - Create the user account that the Splunk software should run as. For example, if the
splunk
user should run the software:[sudo] mkuser splunk [sudo] chown -R splunk <Splunk directory>
- Change to the Splunk bin directory.
- Enable boot start and specify the
-user
flag with the user that the software should run as.[sudo] ./splunk enable boot-start -user <user that Splunk should run as>
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.
- Log into your machine.
- Open the Terminal app.
- Change to the Splunk bin directory:
cd /Applications/Splunk/bin
- Enable boot start:
[sudo] ./splunk enable boot-start
Enable boot-start on MacOS as a non-root user
- Log into your machine.
- Open the Terminal app.
- Change to the Splunk bin directory:
cd /Applications/Splunk/bin
- Enable boot start:
[sudo] ./splunk enable boot-start -user <user Splunk Enterprise should run as>
- Open
/Library/LaunchItems/com.splunk.plist
for editing. - Locate the line that begins with
<dict>
. - Immediately after this line, add the following block of code:
<key>UserName</key> <string><user Splunk Enterprise should run as></string>
- Save the file and close it.
Changes take effect the next time you boot the machine.
Disable boot-start
If you want to stop Splunk software from running at machine boot time, run:
[sudo] $SPLUNK_HOME/bin/splunk disable boot-start
Disable boot-start on Windows
By default, Splunk starts automatically when you start your Windows machine. You can configure the Splunk processes (splunkd
and splunkweb
) to start manually from the Windows Services control panel.
Get more help on boot-start
To learn more about boot-start and how to enable it, see the following:
- The file
$SPLUNK_HOME/etc/init.d/README
- The output from the
$SPLUNK_HOME/bin/splunk help boot-start
command on your Splunk software instance.
Start and stop Splunk Enterprise | Run Splunk Enterprise as a systemd service |
This documentation applies to the following versions of Splunk® Enterprise: 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10
Feedback submitted, thanks!