简体   繁体   中英

Run a bash script to shutdown tomcat from another directory

I have two scripts, one to run the application shutdown for Tomcat server, and another that calls it when deploying. So basically after Jenkins builds my application, and moves the deploy-able artifact to the server (linux). Once that completes Jenkins kicks off a script to do the deployment of the application on Tomcat. That deployment script calls another script to shutdown the currently running application on tomcat. The problem I'm having is that it doesn't recognize anything is running on Tomcat. So I end up with two instances of the application running at the same time on the server...and I get out of memory exceptions. So this is the strange part. If I try to run the script as sudo /path/to/my/script stop it doesn't recognize any application running on tomcat, but if I cd to the directory like cd /path/to/my and then run sudo ./script stop it works. Does anyone know what the issue is? I don't think this has to do with permissions, I am using the same user to do everything, build and deploy. All files are owned by the same user, and I'm using sudo before the command. Thanks in advance for your help.

Without knowing what script does, this is the best you can do

(cd path/to/my && sudo ./script stop)

you can create an alias or a function if you like.

What you actually want is to run hybris as a service and then start/stop this service.

On unix I will go with systemd and System CTL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM