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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:19:38+00:00 2026-06-15T19:19:38+00:00

There are several entries on this subject, for example here and enter , but

  • 0

There are several entries on this subject, for example here and enter, but none of the suggestion does seem to work. I have an example here:

$pid = shell_exec("nohup sleep 10 2> /dev/null & echo $!");
echo $pid;

which I expect to start a new command sleep 10 in the background, and return immediately to the shell. But the found behavior is that this code ‘waits’ for the execution of the subcommand sleep 10.

How can I run my commad in the background as a new process?

  • 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-15T19:19:39+00:00Added an answer on June 15, 2026 at 7:19 pm

    According to some notes to nohup on the wikipedia page, some shells deny to close unless all streams are free again.

    A workaround therefore is to redirect all three standard streams: output, error and input, like in the following example:

    nohup ./myprogram > foo.out 2> foo.err < /dev/null &
    

    It is merely a guess, but that could probably be the case in your scenario.

    $pid = shell_exec("nohup sleep 10 > /dev/null 2> /dev/null < /dev/null & echo $!");
    echo $pid;
    

    You might want to give this a try. I hope this is helpful even in case it does not answer your question.

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

Sidebar

Related Questions

There are several threads on this here at SO but I didn't find one
There are several other questions about this topic that I have gone through, but
There are several variant questions on this on SO, but I did not find
I have large chunks of data, normally at around 2000+ entries, but in this
I've been working on a page where there are several entries contained in different
I have several csv's that look like this: I have several large text files
I have property file called person.properties . I need to add several person entries
I've read several posts here about ignoring files in Mercurial but I'm stumped on
I have a file which contains several text entries, say one two three Now,
I have an application with entries and containers. There is a ManyToMany relationship between

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.