Command shortcut to ./startup.sh Tomcat

2

Every time I need to start or stop Tomcat, I am navigating to:

 /Tomcat_Dir/bin

and once I am in the folder I enter:

./Startup.sh

And to stop the server, I navigate to the same directory and enter:

 ./Shutdown.sh

I was wondering if there was a way in Linux to alias the above described process, so that from any location in the filesystem, I can simply type in something like

StartTomcat or StopTomcat to perform the Startup and Shutdown of the web-server?

sc_ray

Posted 2011-09-19T19:39:38.447

Reputation: 135

Answers

2

You don't even need to navigate to these directories. Just use the full paths instead:

/Tomcat_Dir/bin/Startup.sh
/Tomcat_Dir/bin/Shutdown.sh

With those, you can create an alias, as you said:

alias StartTomcat='/Tomcat_Dir/bin/Startup.sh'
alias StopTomcat='/Tomcat_Dir/bin/Shutdown.sh'

Add these lines to your ~/.bash_profile, ~/.profile, or ~/.bashrc (whichever you're using – what is the difference?), restart the shell, and you're done.

slhck

Posted 2011-09-19T19:39:38.447

Reputation: 182 472

This is great. I had to use sudo alias StartTomcat='sudo /Tomcat_Dir/bin/Startup.sh' – Andrew Johnston – 2016-05-25T16:14:34.157

3

I know of three easy options -

1) You can add the /Tomcat_Dir/bin to your PATH.

open your .bashrc and edit/add the following

PATH=$PATH:/Tomcat_Dir/bin/


2) Add links to the startup and shutdown scripts in you bin directory.

ln -s /Tomcat_Dir/bin/Startup.sh /bin/tom_start.sh

ln -s /Tomcat_Dir/bin/Shutdown.sh /bin/tom_stop.sh


3) Alias the startup and shutdown scripts.

alias Tomstart='/Tomcat_Dir/bin/Startup.sh'

alias Tomstop='/Tomcat_Dir/bin/Shutdown.sh'

bryan

Posted 2011-09-19T19:39:38.447

Reputation: 7 848