Starting and Stopping Karaf

This chapter describes how to start and stop Apache Karaf and the various options that are available.

Starting Karaf

On Windows

From a console window, change to the installation directory and run Karaf. For the binary distribution, go to

cd [karaf_install_dir]

where karaf_install_dir is the directory in which Karaf was installed, e.g., c:\Program Files\apache-karaf-x.y.

Then type:

bin\karaf.bat

On Unix

From a command shell, change to the installation directory and run Karaf. For the binary distribution, go to

cd [karaf_install_dir]

where karaf_install_dir is the directory in which Karaf was installed, e.g., /usr/local/apache-karaf-x.y.

Then type:

bin/karaf

Warning

Do NOT close the console or shell in which Karaf was started, as that will terminate Karaf (unless Karaf was started with nohup).

Starting Karaf without console

Karaf can be started without the console if you don't intend to use it (one can always connect using the remote ssh access) using the following command:

bin\karaf.bat server

or, on Unix:

bin\karaf server

Starting Karaf in the background

Karaf can be easily started as a background process using the following command:

bin\start.bat

or, on Unix:

bin\start

Starting Karaf from clean

Karaf can be reset to a clean state by simply deleting the [karaf_install_dir]/data folder.
For convenience, a parameter on the karaf and start scripts is available:

bin/start clean

Stopping Karaf

For both Windows and Unix installations, you can perform a clean shutdown of Karaf by using the following command when inside a Karaf console:

osgi:shutdown

or simply:

shutdown

The shutdown command asks you to confirm that you really want to shutdown. If you are sure about the shutdown and avoid the confirmation message, you can use the -f or --force option:

osgi:shutdown -f

It's also possible to delay the shutdown using the time argument. The time argument can have different formats. First, it can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits). Second, it can be in the format +m, in which m is the number of minutes to wait. The work now is an alias for +0.

The following command will shutdown Karaf at 10:35am:

osgi:shutdown 10:35

The following command will shutdown Karaf in 10 minutes:

osgi:shutdown +10

If you're running from the main console, exiting the shell using logout or Ctrl+D will also terminate the Karaf instance.

From a command shell, you can run the following command:

bin\stop.bat

or, on Unix:

bin/stop