How to start keycloak automatically on server reboot

How can i automate this so it runs when ubuntu starts.

cd /otp/keycloak/bin
sudo nohup ./ - bmanagement 0.0 offset = 100 

You can do this with init.d or systemd scripts. Keycloak already come with samples scripts in folder keycloak/docs/contrib/scripts.

Please, read

Here a tutorial about systemd:

You can turn it to a service, as @claudioweiler mentioned (init.d or systemd).
If it’s systemd, check out this site:

Just add a service configuration to the /etc/systemd/system

Then use systemctl enable on your newly created service to start it on every reboot.

Check this out:

1 Like

Hey thanks for the link but in there you just specify the scripts location like /path/ .
I want to run it with those parameters

sudo nohup ./ - bmanagement 0.0 offset = 100

So i am not sure how is it possible.

Just write it as you want with all of the parameters in the ExecStart value, you could add also a User.
Just play with it.

ExecStart=/ arg1 arg2 arg3

Take a look on sample scripts provided with keycloak, you can adjust them easily.

Does one need besides the download of “keycloak-12.0.4” as ZIP-file (distribution powered by WildFly) an extra installation of wildfly?

I have tried to put the standalone distribution under “/opt/” and start it, unfortunately without success, because after starting keycloak via “/opt/keycloak/bin/ -b” the service is terminated as soon as an input is made on the server and keycloak is terminated.

That’s all you need.
1)cd /opt
2)wget keycloak
4)cd keycloak/bin
5)sudo ./ - bmanagement

1 Like

Many thanks @gradCoder

I have finished my installation so far and also access via the URL.

As @claudioweiler commented, keycloak is shipped with examples that are delivered in zip-file

I had a look at the sample files in the ZIP directory “…\keycloak-12.0.4\docs\contrib…” but i wasn’t able to start keycloak as a standalone service in the background when my Cent os 7 is rebooting



ExecStart=KEYCLOAK_HOME/bin/ -b


Does keycloak come with its own database or do you have to take care of storing the settings additionally here (What would be the best approach here)?

I havent made the reboot thing yet .

It comes with a pre configured database (that’s how u can deploy it instantly) but i think it’s advice to install your own db .

1 Like

How is it possible that keycloak is permanently running and available in your environment @gradCoder? The service stops as soon as you start another action on the server.

Maybe you can test it? Which operating system do you use

I have also tried to put keycloak behind a reverse proxy like nginx or Apache HTTP Server.

I use nohup so it runs on the background so even if i close the terminal it won’t close .
The command looks like this

sudo nohup ./ - bmanagement &

i think instead of aberrant at the end u may need dot or something else i dont remember and dont have access to the server to check the command rn.

But that wont work if someone reboots the machine , you will need to do it again so i am looking to automate this as well so it always starts with the server.

I just use ubuntu.

1 Like

Many thanks for your help

I’ll try to practice with it and share my results

Does the Keycloak with the version “Keycloak on OpenJDK” compared to “Keycloak on Docker” or “Keycloak on Podman” provide this same basic functionality from the start without having to integrate extensions like adapters or the like?

Is it necessary for the connection of keycloak as SSO in front of other login pages of applications that they support OIDC or SAML on the other side?

Please do share if you manage to make it auto start.

No you still have to configure it . You don’t need an adapter unless you are using it on an application that doesn’t support openID .

If openID is supported by the application you will just create a client into keycloak and link endpoints found on ur json of ur realm to that application.

It’s pretty easy.

1 Like

Can someone explain to me where the difference between “./ -b” and “./ -b -b management” is?

Does the management has to be started here as well or what additional benefit does it offer?

./ -b

Bind just default interface (applications) to the wild.

./ -b -b management

Binds default and management interfaces to the wild.

Does the management has to be started

It’s always started.

1 Like