Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I have my bash script stop Jira?

MP32
Contributor
November 15, 2022

I'm trying to have a bash script stop jira, but I'm getting errors no matter which way I try. I'm trying to run sudo /opt/atlassian/jira/bin/stop-jira.sh or sudo /opt/atlassian/jira/bin/shutdown.sh and get this error:

PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted.

I switched to the root user which is what Jira runs as and I don't have any issues starting Jira with a bash script or running the equivalent commands to start it, but why does it not work when trying to stop Jira? How would I do this in a bash script?

1 answer

1 accepted

1 vote
Answer accepted
Florian Bonniec
Community Champion
November 15, 2022

Hi @MP32 

You should run Confluence as a service using a user different than root. Using a service will allow you to stop Confluence using service confluence stop.

 

https://confluence.atlassian.com/confkb/run-confluence-as-a-systemd-service-on-linux-937177781.html

 

You can also kill the process directly by searching the pid using ps -edf | grep confluence then kill -9 PID where PID is the PID returned by the previous command.

 

Regards

MP32
Contributor
November 15, 2022

I was hoping to do this with a bash script, is it normal set it as a service and add that service.config file as part of a bash script? I've actually never done that before, so I'm not sure if it's common or not

Florian Bonniec
Community Champion
November 16, 2022

You do not need to update the bash script, using JIRA as a service is the most common implementation.

The other way is as describe, using the ps and kill command, but it's not the rocommanded one.

Regards

MP32
Contributor
November 16, 2022

I followed the doc for setting JIRA as a service and I'm running into some errors when trying to start JIRA. When I run journalctl -xe to view the errors I get:

- touch: cannot touch '/opt/atlassian/jira/logs/catalina.out': Permission denied

- opt/atlassian/jira/bin/catalina.sh: line 516: /opt/atlassian/jira/logs/catalina.out: Permission denied

- Tomcat started.

- Failed to parse PID from file /opt/atlassian/jira/work/catalina.pid: Invalid argument

- Failed to start Jira.

Florian Bonniec
Community Champion
November 16, 2022

The user you have selected in the service do not have proper permission on the folder.

Florian Bonniec
Community Champion
November 16, 2022

@MP32 

I noticed that I pointed you to Confluence page not JIRA but it should be the same, please find below the JIRA doc

https://confluence.atlassian.com/jirakb/run-jira-as-a-systemd-service-on-linux-979411854.html

 

Because you are not running JIRA as root (not a good practice to use root) you face permission issues. Please have a look to the doc to install JIRA.

https://confluence.atlassian.com/adminjiraserver/installing-jira-applications-on-linux-from-archive-file-938846844.html

Regards

Like MP32 likes this
MP32
Contributor
November 17, 2022

I gave the jira user permissions to the entire install and home directory (as per the doc just for testing purposes) and it's still not working. I tried making it root and the jira user and I'm having no luck with neither. If I run systemctl status jira.service

Here's all it says:

jira.service - Atlassian Jira
Loaded: loaded (/usr/lib/systemd/system/jira.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-11-18 01:41:57 UTC; 24s ago
Process: 26919 ExecStart=/opt/atlassian/jira/bin/start-jira.sh (code=exited, status=0/SUCCESS)
Main PID: 26961 (code=exited, status=1/FAILURE)

Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: `UOJ
Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: Atlassian Jira
Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: Version : 8.22.4
Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: If you encounter issues starting or stopping Jira, please see the Troubleshooting guide at https://docs.atlassian.com/jira/jadm-doc...installation
Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: Server startup logs are located in /opt/atlassian/jira/logs/catalina.out
Nov 18 01:41:56 ec2.internal start-jira.sh[26919]: Tomcat started.
Nov 18 01:41:56 ec2.internal systemd[1]: Started Atlassian Jira.
Nov 18 01:41:57 ec2.internal systemd[1]: jira.service: main process exited, code=exited, status=1/FAILURE
Nov 18 01:41:57 ec2.internal systemd[1]: Unit jira.service entered failed state.
Nov 18 01:41:57 ec2.internal systemd[1]: jira.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

Florian Bonniec
Community Champion
November 21, 2022

What your service file looks like ?

Suggest an answer

Log in or Sign up to answer