How to auto start Confluence when booting on CentOs 5.4

Currently I am setting up Confluence in a CentOs 5.4 environment. As I want it to start automatically when booting some figuring out had to be done. This procedure also works for Jira and Crowd by the way. Here are the results. FYI: we use Apache httpd and the Apache Tomcat connector to connect http daemon port 80 to our Tomcat port, this post will not dig into that subject.

For security reasons you’d want to run Confluence using a dedicated user with limited privileges. So we create a user called confluence. By default you cannot use this account to login, but we don’t need that.

useradd -m confluence

Now we make the user owner of the folders that Confluence is using (change the folder names to the names that you are using).

chown -R confluence /opt/confluence-3.1.1-std
chown -R confluence /var/confluence

When this is done we can test if the confluence user can stop and start Confluence. We use the su command to execute the scripts being the confluence user. First we shut Confluence down (assuming it is running already) and then we start it up again.

cd /opt/confluence-3.1.1-std/bin

su confluence -c ./

su confluence -c ./

It can take some time to get it back up, so be patient and hit F5 a few times in your browser. Also, take a look at the log files in the logs folder if you are unsure or need to know a bit more about what is going on or going wrong.

Now we have confirmed that we are able to start and stop Confluence using our dedicated user we will create a script that allows us to run Confluence as a service. This means we can start, stop and ask about its status like any other service. Use nano to create the script:

nano /etc/init.d/confluence

Now copy and paste the following script. Adjust folder names to match your own situation. As Confluence standalone comes with Tomcat integrated, it basically is an adjusted Tomcat script. Beware: the script might contain some linefeeds which you need to remove to have it run properly.



# Startup script for Tomcat/Confluence


# chkconfig: 345 84 16

# description: Tomcat/Confluence server

# processname: confluence

#Necessary environment variables

export CATALINA_HOME=”/opt/confluence-3.1.1-std”

if [ ! -f $CATALINA_HOME/bin/ ]


echo “Tomcat not available…”



start() {

echo -n -e ‘\E[0;0m'”\033[1;32mStarting Tomcat: \033[0m \n”

su -l confluence -c $CATALINA_HOME/bin/


touch /var/lock/subsys/confluenced

sleep 3


stop() {

echo -n -e ‘\E[0;0m'”\033[1;31mShutting down Tomcat: \033[m \n”

su -l confluence -c $CATALINA_HOME/bin/

rm -f /var/lock/subsys/confluenced



status() {

ps ax –width=1000 | grep “[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’ | wc | awk ‘{print $2}’ > /tmp/tomcat_process_count.txt

read line < /tmp/tomcat_process_count.txt

if [ $line -gt 0 ]; then

echo -n “confluenced ( pid “

ps ax –width=1000 | grep “[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’

echo -n “) is running…”



echo “Tomcat is stopped”



case “$1” in









sleep 3







echo “Usage: confluenced {start|stop|restart|status}”

exit 1


Because the script needs to be executed we have to allow execution:

chmod +x /etc/init.d/confluence

The final steps are to add the service and to switch it on.

chkconfig –add confluence

chkconfig confluence on

If all goes well you should be able to reboot and have a running Confluence instance when it finishes. Make sure that the other required services are running as well (database, httpd, ..). You can check and change their settings by using the setup command.

Please leave a comment if you’d like to suggest an improvement.

Leave a Reply

Your email address will not be published. Required fields are marked *