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 269579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:51:35+00:00 2026-05-11T23:51:35+00:00

In a sort of try/catch form I want to execute a bash that doesn’t

  • 0

In a sort of try/catch form I want to execute a bash that doesn’t stop if an error occurs.

The specific bash is:

#!/bin/sh

invoke-rc.d tomcat stop

rm -fr /var/webapps/
cp -R $WEBAPP /var/webapps/
invoke-rc.d tomcat start

I want to exec “invoke-rc.d tomcat stop” and even if Tomcat is not running, continue to execute the other bash commands.

  • 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-05-11T23:51:36+00:00Added an answer on May 11, 2026 at 11:51 pm

    Try:

    invoke-rc.d tomcat stop > /dev/null 2>&1 || true
    

    A little background:

    user@tower: # true
    user@tower: # echo $?
    0
    user@tower: # false
    user@tower: # echo $?
    1
    
    user@tower: # which true
    /bin/true
    user@tower: # which false
    /bin/false
    

    The real solution is looking at the tomcat init script to see how it knows if tomcat is running 🙂 That way, you don’t pester it needlessly.

    See this post on the other suggestion to unset / set +e. While it would solve your immediate problem, you may find that you need the recently unset behavior in your own script, especially since you are copying files.

    This is one of the biggest reasons why true and false were made, other than making Makefiles behave as expected in a variety of build environments.

    Also, set +e is not entirely portable, i.e. some versions of Solaris (and even Dash) .. but I doubt that this is a concern for you.

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

Sidebar

Related Questions

Is it possible to do some sort of try catch that will catch warnings?
I am trying to build some sort of a javascript antivirus that would try
Is there some sort of try/catch function in obj-c? I'm trying to load saved
Okay, I have a try..catch such that : Try Dim dr As OleDbDataReader =
...@Sort bit) AS SELECT .............. and I want to Order only if Sort =
Sort of a methods/best practices question here that I am sure has been addressed,
i want to sort dictionary based upon value of each dictioanry item.but if i
I'm trying to write my first semi advanced bash script that will take input
I have code within a try/catch block with a redirect to another page. If
What I want is a standard JDK class that look like this: interface ExplodingRunnable

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.