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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:26:56+00:00 2026-05-25T06:26:56+00:00

I have a few questions regarding an init script I’m writing. I haven’t actually

  • 0

I have a few questions regarding an init script I’m writing. I haven’t actually done it from scratch before so there are probably several tips and tricks I don’t know about. Also, shell script is not something I have used a lot so the syntax took a bit of getting used to.

First of all I have a function to see if the application is running. The reason for this, instead of lockfiles or similar, is that I only want ONE instance and the application is a bit buggy and plugins can sometime linger even if the main application is killed.

So I have something like.

isrunning() {
  pids=`ps aux | grep -e 'FooBar' | grep -v grep | awk '{print $2}'`
  if [ ! -n "$pids" ]; then
    return 1
  else
    return 0
  fi
}

Is there a better way?

I start the main application with

daemon --user apache "./FooBar"

but that hung the script execution on that line until FooBar was terminated.

daemon --user apache "FooBar&"

works though. But it looks like the [OK] / [FAILED] that shows up when running the init script is actually output by the daemon function? So even if the execution fails, daemon still reports [OK] since the process of FooBar is detached.

Is there a way to get daemon NOT to get stuck without detaching the process? I have tried the -d option etc but no luck.

Otherwise I was thinking of just doing a sleep 3 and then check isrunning which works fine. But then I don’t know how to print the [OK] / [FAILED] messages in the nice pretty way that init scripts normally do. Is there perhaps a function one can use to print this in the standard form?

UPDATE

I found the solution to printing the messages. It seems it actually are functions for this.
success and failure will print the messages.

The daemon issue remain though. Any way to get rid of &?

UPDATE 2

I found a workaround and used

su -m -c "./FooBar&" apache

and checking if the application was running after that. Depending on the result I print the correct message.

  • 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-25T06:26:57+00:00Added an answer on May 25, 2026 at 6:26 am

    I found the solution to printing the messages. It seems it actually are functions for this. success and failure will print the messages.

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

Sidebar

Related Questions

There have been a few questions regarding this issue before; my understanding is that
I have a few questions regarding Google Chart Tools. Do we actually need a
I have a few questions regarding a PHP Pagination Script For Flat File Database
I'm very new to TDD world. I have a few questions regarding TDD. Do
I have a few basic questions regarding the syntax and usage of properties in
I have a few questions regarding JavaScript obfuscation on client side. First question :
I have a few questions regarding differentiation between const and non-const versions of methods
I am a beginner to networking and I have a few questions regarding networking.
I know there are a few questions regarding the libraries you can use to
There are several/many questions regarding TFS branching strategy, but I am haven't been able

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.