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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:59:21+00:00 2026-05-24T16:59:21+00:00

Possible Duplicate: php exec command (or similar) to not wait for result I have

  • 0

Possible Duplicate:
php exec command (or similar) to not wait for result

I have a page that runs a series of exec() commands which forces my PHP script to halt alteration until it receives a response. How can I tell exec() to not wait for a response and just run the command?

I’m using a complex command that has a backend system I can query to check the status, so I’m not concerned with a response.

  • 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-24T16:59:22+00:00Added an answer on May 24, 2026 at 4:59 pm

    Depends on what platform you are using, and the command you are running.

    For example, on Unix/Linux you can append > /dev/null & to the end of the command to tell the shell to release the process you have started and exec will return immediately. This doesn’t work on Windows, but there is an alternative approach using the COM object (See edit below).

    Many commands have a command line argument that can be passed so they release their association with the terminal and return immediately. Also, some commands will appear to hang because they have asked a question and are waiting for user input to tell them to continue (e.g. when running gzip and the target file already exists). In these cases, there is usually a command line argument that can be passed to tell the program how to handle this and not ask the question (in the gzip example you would pass -f).

    EDIT

    Here is the code to do what you want on Windows, as long as COM is available:

    $commandToExec = 'somecommand.exe';
    $wshShell = new COM("WScript.Shell");
    $wshShell->Run($commandToExec, 0, FALSE);
    

    Note that it is the third, FALSE parameter that tells WshShell to launch the program then return immediately (the second 0 parameter is defined as ‘window style’ and is probably meaningless here – you could pass any integer value). The WshShell object is documented here. This definitely works, I have used it before…

    I have also edited above to reflect the fact that piping to /dev/null is also required in order to get & to work with exec() on *nix.

    Also just added a bit more info about WshShell.

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

Sidebar

Related Questions

Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: PHP - How to split a paragraph into sentences. I have a
Possible Duplicate: Why PHP variables start with a $ sign symbol? I have looked
Possible Duplicate: php in background exec() function I am trying to run two exec
Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some
Possible Duplicate: php scandir --> search for files/directories I have a folder, inside this
Possible Duplicate: php headers already sent error I have attached my code which am
Possible Duplicate: PHP syntax for dereferencing function result If a PHP function returns an
Possible Duplicate: PHP 5.3 changelog? I am new to PHP, and I am confused
Possible Duplicate: PHP: How To Disable Dangerous Functions Hi, this is my situation: I

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.