I used to start Solr with this command:

java -jar start.jar

and all I had to do to stop it was press Control + C

But then I started it this way:

java -jar start.jar &

Which starts it as a background process so I can get the shell back after it starts. But now I don't know how to stop it. I am using Ubuntu Server.


You started the process and put it in the background. List background processes with the jobs command.

To bring background processes to the foreground, use fg [job number]. From there, you can exit them as normal.


In light of new information, the problem has nothing to do with foreground and background processes. Apparently the process is being started in the background, and then the terminal window is being closed. Thus, it's not a job attached to the terminal anymore.

In this case, you simply kill the process associated with Solr. Use ps to find the process and kill to stop it.

  • I don't have the "jobs" command, do you know the package name so I install is via apt-get? "sudo apt-get install jobs" didn't work. – JakeRow123 Apr 21 '12 at 4:31
  • @JakeRow123 jobs should be a bash builtin, not a package. What is the result of running echo $SHELL? – Wesley Apr 21 '12 at 4:38
  • result is "/bin/bash", according to this post: superuser.com/questions/152767/…, "jobs displays the status of jobs in the current session". I started Solr inside vmware a few days ago from another terminal window than the one I am working in atm. So maybe that's why it doesn't display anything. I tried "ps -e" which shows several "jetty" processes but when I try to bring them to the foreground using fg [their job number], it just says "no such jobs". Solr runs via jetty so I figured stopping that would stop Solr. – JakeRow123 Apr 21 '12 at 4:45
  • killing the jetty services didn't work, after killing them and doing another ps -e command, they showed up again. But killing the java service did stop solr. Don't think this is the proper way but it will do for now. Thanks. – JakeRow123 Apr 21 '12 at 5:06

Create a deamon, mondify the paths according to your needs.

enter code here Steps to install SOLR as a daemon

create /etc/init.d/solr.production and copy the below contents into the file. Please change all necessary paths.
change directory to /etc/init.d
run sudo /sbin/chkconfig --add solr.production
run sudo /sbin/service solr.production start
run ps -Af | grep start.jar to check that it is running
run cat /var/run/solr.production.pid (change path if needed) to see if PID value is correct.


# chkconfig: 2345 98 02
# description: Starts and stops Solr production

# source function library
. /etc/rc.d/init.d/functions

set -e



START_COMMAND="/usr/lib/jdk1.6.0_03/bin/java -Xms512M -Xmx1024M -jar start.jar"
NAME="Solr (production)"

start() {
  echo -n "Starting $NAME"
  if [ -f $PIDFILE ]; then
    echo -n "$PIDFILE exists. $NAME may be running."
    cd $SOLR_HOME
    sleep 2
    echo `ps -ef | grep -v grep | grep "$START_COMMAND" | awk '{print $2}'` > $PIDFILE
    echo "Done"
  return 0

stop() {
  echo -n "Stopping $NAME"
  kill `cat $PIDFILE`
  echo "Done"
  return 0

case "$1" in
    sleep 5

echo "Usage: $0 (start | stop | restart)"
exit 1

exit $?

Now you can use /etc/init.d/solr stop|start|restart


I got that from lucidWorks/app/bin/stop.sh, I hope it works for you

#!/usr/bin/env bash

# You can override pass the following parameters to this script:
# -lwe_app_dir -lwe_data_dir -lwe_conf_dir -lwe_log_dir


# Find location of this script and go up a level to lucidworksAppHome

sdir="`dirname \"$0\"`"

# Stop the processes

$JVM -jar "$sdir/StartUtil.jar" -jvm_cmd $JVM ${1+"$@"} stop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.