Run as a Service

When installing Nexus Repository Manager for production usage it has to be configured it to run as a service, so it restarts after the server reboots. It is good practice to run that service or daemon as a specific user that has only the required access rights. Installation from the distribution archive does not include the configuration of a service. The following sections provide instructions for configuring the service manually. Independent of the operating system the steps are:

  • Create operating system user with limited access rights dedicated to run the repository manager as a service
  • Ensure suitable Java runtime environment is installed - see Java Runtime Environment
  • Configure the service and ensure it starts as part of the operating system boot process


You can configure the repository manager to run as a service with  init.d or  systemd . Both are startup frameworks used in Linux-based systems such as Ubuntu and CentOS. They are, essentially, initscripts that load commands to manage the repository manager daemon. Before running the service configure an absolute path for your repository manager files. Then create a nexus user with sufficient access rights to run the service. Change  NEXUS_HOME  to the absolute folder location in your  .bashrc  file, then save.


In  bin/nexus.rc  assign the user between the quotes in the line below:


If you use  init.d  instead of  systemd , symlink  $NEXUS_HOME/bin/nexus  to  /etc/init.d/nexus:

sudo ln -s $NEXUS_HOME/bin/nexus /etc/init.d/nexus


This example uses chkconfig, a tool that targets the initscripts in init.d to run the nexus service. Run these commands to activate the service:

cd /etc/init.d
sudo chkconfig --add nexus
sudo chkconfig --levels 345 nexus on
sudo service nexus start

The second command adds nexus as a service to be started and stopped with the command.  chkconfig manages the symbolic links in /etc/rc[0-6].d  which control the services to be started and stopped when the operating system restarts or transitions between run-levels. The third command adds nexus to run-levels 3, 4 and 5. Then the service command starts the repository manager.


This example uses update-rc.d, a tool similar to the chkconfig.

cd /etc/init.d
sudo update-rc.d nexus defaults
sudo service nexus start

In the second line you will run a default priority to add the nexus service before starting it.


This example is a script that uses systemd to run the repository manager service. Create a file called nexus.service. Add the following contents, then save the file in the  /etc/systemd/system/ directory:

Description=nexus service
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop

Activate the service with the following commands:

sudo systemctl daemon-reload
sudo systemctl enable nexus.service
sudo systemctl start nexus.service

After starting the service for any Linux-based operating systems, verify that the service started successfully.

tail -f /opt/sonatype-work/nexus3/log/nexus.log

The tail command verifies that the service has been started successfully. If successful, you should see a message notifying you that it is listening for HTTP.

Be sure to assign the appropriate permissions to the user running the nexus service.

PID File

When started as a service on Linux, NXRM will create a file which holds a process ID in the operating system /tmp directory.  This file will have have a name of the form:

  • prefix: "i4jdaemon_"
  • suffix: the absolute path to the nexus start script with path part separators replaced with underscores
    Example: Temporary directory is /tmp and path to start script is at /opt/nexus/nexus-3.14.0-04/bin/nexus , then the file created will be at "/tmp/i4jdaemon__opt_nexus_nexus-3.14.0-04_bin_nexus". 

If the service pid file cannot be written the service startup will silently fail, without any logging statements written to the nexus.log

If the NXRM process is already stopped, and the service is failing to start, first confirm there is no log output being added to the nexus.log file. If not, then check for an pre-existing pid file. If that file is present, delete it first before trying to start the service.

The directory this file is created in can opttionally be changed by editing $install-dir/bin/nexus.vmoptions and adding a line like this:


The directory specified by the propery must already exist for the property to work - the directory will not be created automatically.


The startup script that runs Nexus Repository Manager Pro and Nexus Repository Manager OSS on Windows platforms is  bin/nexus.exe. The script includes standard commands for starting and stopping the service. It also contains commands  install  and  uninstall  to create and delete the configuration for the service. You can create the service configuration with:

nexus.exe /install <optional-service-name>

The new service is named  nexus  by default. It is available in the Windows console application to manage services such as Windows Services. You can start, stop and restart the service there as well as configure it to start as part of a operating system startup. Alternatively you can manage the service on the command line:

nexus.exe /start <optional-service-name>
nexus.exe /stop <optional-service-name>
nexus.exe /uninstall <optional-service-name>

The <optional-service-name> parameter with a value of e.g. nexus3 can be used to create a service that does not collide with an existing service established for Nexus Repository Manager 2 running on the same server.

Mac OS X

The standard way to run a service on Mac OS X is to use  launchd , a program that starts, stops and manages daemons and scripts in Apple OS X environments. To run the service you need to create an XML document called with the file extension  .plist  to define its properties. An example plist file for the repository manager installed in  /opt  is shown here:

A sample file
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
<plist version="1.0">

After saving the file as  in  /Library/LaunchDaemons/  you have to change the ownership and access rights:

sudo chown root:wheel /Library/LaunchDaemons/
sudo chmod 644 /Library/LaunchDaemons/

Consider setting up a different user to run the repository manager and adapt permissions and the RUN_AS_USER setting in the nexus startup script. With this setup the repository manager starts as a service at boot time. To manually start it after the configuration you can use:

sudo launchctl load /Library/LaunchDaemons/