Automatic startup service on CentOS 7
Asked by Po??? B???????????:

Hello. How can I add to startup service Confluence on **CentOS 7**? After restarting the server, the service does not start.

P.S. [This solution](https://confluence.atlassian.com/confkb/run-confluence-as-a-systemd-service-on-linux-937177781.html) is not work


Answers:
author: Shannon S
body: Hello there,

Welcome to Atlassian Community! It's nice to have you.

To run Confluence as a service on Linux, you must use `sudo` to run the installer to be able to install Confluence as a service. The installer will create a dedicated user account, `confluence`, that will run the service.

Can you confirm that you used sudo to run the installer? Are you getting any error messages when the service tries to start?

Regards,

Shannon

comments: author: Po??? B???????????
body: I tried to run this script, but I get an error:

\[root@confluence user\]# su - root  
\[root@confluence \~\]# cd /opt/atlassian/confluence/bin/  
\[root@confluence bin\]# sudo sh install_linux_service.sh  
installing Confluence as a service  
which: no update-rc.d in (/sbin:/bin:/usr/sbin:/usr/bin)  
ln: failed to create symbolic link \<\</etc/rc0.d/K95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc1.d/K95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc2.d/S95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc3.d/S95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc4.d/S95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc5.d/S95confluence1\>\>: File exists  
ln: failed to create symbolic link \<\</etc/rc6.d/K95confluence1\>\>: File exists  
\[root@confluence bin\]#


author: Po??? B???????????
body: I tried to create a file:  
**/lib/systemd/system/confluence.service**

with content:

*\[Unit\]*   
*Description=Confluence*   
*After=network.target* *\[Service\]*   
*Type=forking*   
*User=confluence*   
*PIDFile=/opt/atlassian/confluence/work/catalina.pid*   
*ExecStart=/opt/atlassian/confluence/bin/start-confluence.sh*   
*ExecStop=/opt/atlassian/confluence/bin/stop-confluence.sh*   
*TimeoutSec=200*   
*LimitNOFILE=4096*   
*LimitNPROC=4096*

*\[Install\]*   
*WantedBy=multi-user.target*


author: Po??? B???????????
body: \[root@confluence system\]# **systemctl daemon-reload**

\[root@confluence system\]# **systemctl enable confluence.service**   
Failed to execute operation: File exists

\[root@confluence system\]# **systemctl start confluence.service**   
Job for confluence.service failed because the control process exited with error code. See "systemctl status confluence.service" and "journalctl -xe" for details.

\[root@confluence system\]# **systemctl status confluence.service**   
? confluence.service - Confluence  
Loaded: loaded (/etc/systemd/system/confluence.service; enabled; vendor preset: disabled)  
Active: failed (Result: exit-code) since ?? 2019-10-15 04:36:46 MSK; 2s ago  
Process: 1498 ExecStart=/opt/atlassian/confluence/bin/start-confluence.sh (code=exited, status=1/FAILURE)

??? 15 04:36:46 confluence.loc systemd\[1\]: Starting Confluence...  
??? 15 04:36:46 confluence.loc start-confluence.sh\[1498\]: To run Confluence in the foreground, start the server with start-confluence.sh -fg  
??? 15 04:36:46 confluence.loc systemd\[1\]: confluence.service: control process exited, code=exited status=1  
??? 15 04:36:46 confluence.loc systemd\[1\]: Failed to start Confluence.  
??? 15 04:36:46 confluence.loc systemd\[1\]: Unit confluence.service entered failed state.  
??? 15 04:36:46 confluence.loc systemd\[1\]: confluence.service failed.  
\[root@confluence system\]#


author: Po??? B???????????
body: \[root@confluence system\]# **journalctl -xe**   
-- ??????? ??????? ?????? ?????? ????? ?????????????? 1313.  
??? 15 04:24:11 confluence.loc sshd\[1313\]: pam_unix(sshd:session): session opened for user user by (uid=0)  
??? 15 04:24:15 confluence.loc su\[1337\]: (to root) user on pts/0  
??? 15 04:24:15 confluence.loc su\[1337\]: pam_unix(su:session): session opened for user root by user(uid=1000)  
??? 15 04:24:42 confluence.loc su\[1350\]: (to root) user on pts/0  
??? 15 04:24:42 confluence.loc su\[1350\]: pam_unix(su-l:session): session opened for user root by user(uid=0)  
??? 15 04:35:09 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1430:202873 (system bus name :1.27 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:35:09 confluence.loc systemd\[1\]: Reloading.  
??? 15 04:35:09 confluence.loc systemd\[1\]: \[/etc/systemd/system/node_exporter.service:10\] Unknown lvalue 'ExecLoad' in section 'Service'  
??? 15 04:35:09 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1430:202873 (system bus name :1.27, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)  
??? 15 04:35:13 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1448:203290 (system bus name :1.28 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:35:13 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1448:203290 (system bus name :1.28, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)  
??? 15 04:35:20 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1454:203906 (system bus name :1.29 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:35:20 confluence.loc systemd\[1\]: Starting Confluence...  
-- Subject: ?????????? ?????? ????? confluence.service  
-- Defined-By: systemd  
-- Support: <http://lists.freedesktop.org/mailman/listinfo/systemd-devel>  
--  
-- ????? ??????? ??????? ????? confluence.service.  
??? 15 04:35:20 confluence.loc start-confluence.sh\[1460\]: To run Confluence in the foreground, start the server with start-confluence.sh -fg  
??? 15 04:35:20 confluence.loc start-confluence.sh\[1460\]: Confluence has been installed to run as confluence1 so please sudo run this to enable switching to that user  
??? 15 04:35:20 confluence.loc systemd\[1\]: confluence.service: control process exited, code=exited status=1  
??? 15 04:35:20 confluence.loc systemd\[1\]: Failed to start Confluence.  
-- Subject: ?????? ????? confluence.service  
-- Defined-By: systemd  
-- Support: <http://lists.freedesktop.org/mailman/listinfo/systemd-devel>  
--  
-- ????????? ???? ????? confluence.service.  
--  
-- ?????????: failed.  
??? 15 04:35:20 confluence.loc systemd\[1\]: Unit confluence.service entered failed state.  
??? 15 04:35:20 confluence.loc systemd\[1\]: confluence.service failed.  
??? 15 04:35:20 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1454:203906 (system bus name :1.29, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)  
??? 15 04:36:39 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1468:211874 (system bus name :1.30 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:36:39 confluence.loc systemd\[1\]: Reloading.  
??? 15 04:36:39 confluence.loc systemd\[1\]: \[/etc/systemd/system/node_exporter.service:10\] Unknown lvalue 'ExecLoad' in section 'Service'  
??? 15 04:36:39 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1468:211874 (system bus name :1.30, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)  
??? 15 04:36:43 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1486:212229 (system bus name :1.31 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:36:43 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1486:212229 (system bus name :1.31, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)  
??? 15 04:36:46 confluence.loc polkitd\[723\]: Registered Authentication Agent for unix-process:1492:212570 (system bus name :1.32 \[/usr/bin/pkttyagent --notify-fd 5 --fallback\], object path /org/freedesktop/PolicyKit1/AuthenticationAgent,  
??? 15 04:36:46 confluence.loc systemd\[1\]: Starting Confluence...  
-- Subject: ?????????? ?????? ????? confluence.service  
-- Defined-By: systemd  
-- Support: <http://lists.freedesktop.org/mailman/listinfo/systemd-devel>  
--  
-- ????? ??????? ??????? ????? confluence.service.  
??? 15 04:36:46 confluence.loc start-confluence.sh\[1498\]: To run Confluence in the foreground, start the server with start-confluence.sh -fg  
??? 15 04:36:46 confluence.loc start-confluence.sh\[1498\]: Confluence has been installed to run as confluence1 so please sudo run this to enable switching to that user  
??? 15 04:36:46 confluence.loc systemd\[1\]: confluence.service: control process exited, code=exited status=1  
??? 15 04:36:46 confluence.loc systemd\[1\]: Failed to start Confluence.  
-- Subject: ?????? ????? confluence.service  
-- Defined-By: systemd  
-- Support: <http://lists.freedesktop.org/mailman/listinfo/systemd-devel>  
--  
-- ????????? ???? ????? confluence.service.  
--  
-- ?????????: failed.  
??? 15 04:36:46 confluence.loc systemd\[1\]: Unit confluence.service entered failed state.  
??? 15 04:36:46 confluence.loc systemd\[1\]: confluence.service failed.  
??? 15 04:36:46 confluence.loc polkitd\[723\]: Unregistered Authentication Agent for unix-process:1492:212570 (system bus name :1.32, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale ru_RU.UTF-8) (disconnected from bus)


author: Po??? B???????????
body: *But I can run this application manually:*

\[root@confluence system\]# **cd /opt/atlassian/confluence/bin/**   
\[root@confluence bin\]#**sh start-confluence.sh**

To run Confluence in the foreground, start the server with start-confluence.sh -fg  
executing using dedicated user: confluence1  
If you encounter issues starting up Confluence, please see the Installation guide at <http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide>

Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out  
---------------------------------------------------------------------------  
Using Java: /opt/atlassian/confluence/jre//bin/java  
2019-10-15 04:44:08,923 INFO \[main\] \[atlassian.confluence.bootstrap.SynchronyProxyWatchdog\] A C ontext element for ${confluence.context.path}/synchrony-proxy is found in /opt/atlassian/conflu ence/conf/server.xml. No further action is required  
---------------------------------------------------------------------------  
Using CATALINA_BASE: /opt/atlassian/confluence  
Using CATALINA_HOME: /opt/atlassian/confluence  
Using CATALINA_TMPDIR: /opt/atlassian/confluence/temp  
Using JRE_HOME: /opt/atlassian/confluence/jre/  
Using CLASSPATH: /opt/atlassian/confluence/bin/bootstrap.jar:/opt/atlassian/confluence/bi n/tomcat-juli.jar  
Using CATALINA_PID: /opt/atlassian/confluence/work/catalina.pid  
Tomcat started.  
\[root@confluence bin\]#

<br />

*...and after a few minutes service is starting.*


author: Shannon S
body: Hello,

Thank you for sharing those details.

The initial error you were getting (failed to get symbolic link) can be ignored; it's expecting init.d there.

The error we want to focus on is this one:

```
[/etc/systemd/system/node_exporter.service:10] Unknown lvalue 'ExecLoad' in section 'Service'
```

There's some value ExecLoad that isn't expected. This isn't in the Service file as instructed in the article ([Run Confluence as a systemd service](https://confluence.atlassian.com/confkb/run-confluence-as-a-systemd-service-on-linux-937177781.html)) so it might be somewhere else in your file.

Can you confirm you ran the following to create the file, and then edit as root?

    touch /lib/systemd/system/confluence.servicechmod 664 /lib/systemd/system/confluence.service

If so, can you please include the contents of the entire file?

Regards,

Shannon


author: Po??? B???????????
body: Hello. Yes, i created this file (*confluence.service* ) with [this](https://confluence.atlassian.com/confkb/run-confluence-as-a-systemd-service-on-linux-937177781.html) solution and with root privilegies and changed it as root user (sorry for my bad english). And i can show this file:

<br />

\[root@confluence system\]# **cat /lib/systemd/system/confluence.service**

\[Unit\]  
Description=Confluence  
After=network.target

\[Service\]  
Type=forking  
User=confluence  
PIDFile=/opt/atlassian/confluence/work/catalina.pid  
ExecStart=/opt/atlassian/confluence/bin/start-confluence.sh  
ExecStop=/opt/atlassian/confluence/bin/stop-confluence.sh  
TimeoutSec=200  
LimitNOFILE=4096  
LimitNPROC=4096

\[Install\]  
WantedBy=multi-user.target  


author: Po??? B???????????
body: I don't quite understand how Confluence works and why the user confluence1 appears in the logs.


author: Po??? B???????????
body: \[root@confluence system\]# **ls -l** \<...\>  
-rw-rw-r-- 1 root root 347 ??? 16 02:45 confluence.service


author: Shannon S
body: Hello,

Thank you for confirming that, and for pointing out the additional Confluence user. This can happen if you've done more than one installation of Confluence on this server

Could you change your username in the Service file to match? (i.e. User=confluence1) Let me know if that helps.

Regards,

Shannon


Tags: centos

startup