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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 238k
  • Answers 238k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's nothing inherently wrong with this snippet, except that you're… May 13, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer You don't have to do anything special, it should just… May 13, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer If you are thinking of implementing something like a typeahead… May 13, 2026 at 6:43 am

Related Questions

In a sort of try/catch form I want to execute a bash that doesn't
What is the best method [pattern] to close a newly opened Windows form in
I'm trying to write my first semi advanced bash script that will take input
I'm referencing the article reference To create a UserControl dynamically and pass it back
Take a .Net Winforms App.. mix in a flakey wireless network connection, stir with

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.