Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:30:14+00:00 2026-06-09T12:30:14+00:00

I am making a shell script to restart tomcat after crash. I wonder I

  • 0

I am making a shell script to restart tomcat after crash.
I wonder I need to handle this message in my script “Tomcat servlet engine is not running, but pid file exists.”
What does this message means?
Do I need to take it into account as an error message that oblige me to restart Tomcat?

My script is as follow:

#!/bin/bash
SERVICE=/etc/init.d/tomcat7
STOPPED_MESSAGE=" * Tomcat servlet container is not running."  
PID_FILE_MESSAGE=" * Tomcat servlet engine is not running, but pid file exists."

if [ "`$SERVICE status`" == "$STOPPED_MESSAGE" ];
then  
{
    $SERVICE start
}
else
    if [ "`$SERVICE status`" == "$PID_FILE_MESSAGE" ];
    then
    {
        $SERVICE restart
    }
    fi
fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:30:15+00:00Added an answer on June 9, 2026 at 12:30 pm

    Here’s the definition of PID. A PID file is a file that contains a process identifier. If Tomcat’s startup scripts are run with CATALINA_PID environment variable set properly, then the PID of the Tomcat process will be recorded to a file upon startup. If the file exists when you try to start Tomcat, the scripts will refuse to run because it does not want to clobber a (possibly valid) PID file.

    If you are sure that Tomcat is not running, simply delete the file (it should be available through the CATALINA_PID environment variable) and try again.

    I share @jordanm’s comment about using exit codes instead of checking for specific (text) output: the latest version of Tomcat does not even use the messages that you have shown above, so it’s very fragile.

    If you want a self-re-starting service, considering looking at jsvc, which actually ships with Tomcat binaries in source form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a shell script that takes a single number (length is unimportant)
I know this is not a straight up question, so if you need me
I am making a shell script that automatically create users, but I cannot think
I'm making a script ( Perl or shell ) that launches a second Perl
I'm making a shell script to find bigrams, which works, sort of. #tokenise words
I'm making a shell script and I want to know if it's possible to
I'm making a shell script with the optparse module, jut for fun, so I
I am making a shell script that will automate the install process of Arch
I have this Shell script and I've managed to muck it up and I
I'm making a .bat-file run a powershell script, and I need to make sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.