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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:33:30+00:00 2026-05-28T04:33:30+00:00

I am testing a php script that has been developed on an OS-X system

  • 0

I am testing a php script that has been developed on an OS-X system at Debian and it behaves different there.

To reproduce it I wrote two scripts: parent.php and child.php:

parent.php:

#!/usr/bin/php
<?php

echo "parent started...\n";
shell_exec(__DIR__ . '/child.php &2>/dev/null &');
echo "parent finished.\n";

child.php:

#!/usr/bin/php
<?php

echo "child started...\n";
sleep(5);
echo "child finished.\n";

Running parent.php on OS-X I get back imediately the two output lines (parent started, parent finished). On Debian I get the “parent started…” line, then a delay of 5 seconds an then the “parent finished.”. Running “./child.php &2>/dev/null &” in the shell gives me back the prompt imediately as expected. Any ideas how I can fix this?

  • 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-28T04:33:31+00:00Added an answer on May 28, 2026 at 4:33 am

    This is because &2> part. It may not be supported in all systems. Also in every shell (bash, sh, ksh etc).

    Try this,

     exec("/bin/bash -c '/usr/bin/php /path/to/child.php 2> /dev/null' &");
    

    If you want to suppress all the output use this,

     exec("/bin/bash -c '/usr/bin/php /path/to/child.php &> /dev/null ' &");
    

    BASH-HOWTO

    Just tested, exec("/usr/bin/php /path/to/child.php > /dev/null 2>&1 &") should work too.

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

Sidebar

Related Questions

I've been testing a PHP script that I'm posting values to every few seconds
I have a php script that outputs json data. For the purposes of testing,
I'm currently PHP building a script that has to update statistics when it finishes
<script type=text/javascript> function testing() { $.ajax({ type: POST, url: testing.php, data: call=+$(#abc).val(), success: function(msg){
I've been testing nuSoap with codeIgniter (PHP Framework) but seems nuSoap isn't prepared to
Im using Debian testing, i have installed php-cli and when i try to execute
I have a php server that is running my domain name. For testing purposes
SOLVED: I wrote and tested a PHP script on the local server. (Nothing fancy,
I wrote a php search script on my site for checking to see if
I have a PHP script that pushes the headers to allow a file to

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.