3

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?

studiohack
  • 13,477
sc_ray
  • 145

2 Answers2

3

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
  • 235,242
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
  • 8,528
  • 4
  • 30
  • 42