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

The Archive Base Latest Questions

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

I want some php script to be launching in a background proccess. For this

  • 0

I want some php script to be launching in a background proccess. For this i have a special method in my class

protected function _runSpider()
{
    $php = exec('which php');
    $result = exec($php . ' ' . Mage::getBaseDir() . '/spider.php > ' . Mage::getBaseDir() . '/var/log/out.log 2>&1 &');
    Mage::log($result);
}

this should execute something like this

/usr/bin/php /home/www/spider.php > home/www/var/log/out.log 2>&1 &

But in result as i think script is not executing, magento log is empty and out.log file is empty.

  • 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-25T15:10:27+00:00Added an answer on May 25, 2026 at 3:10 pm

    Maybe

    protected function _runSpider()
        {
            $command = '$(which php) ' . Mage::getBaseDir() . '/spider.php > ' . Mage::getBaseDir() . '/var/log/out.log');
            $result = exec($command);
            Mage::log($result);
        } 
    

    Removing the last & will lock execution of the script instead of passing control back to the interpreter. And since you’re piping all of the output to a file, maybe you don’t need to pipe the output to null.

    By the way, the shell command you mounted won’t return any data as you’re piping everything to a file or /dev/null. If you need it back to the $result var, remove the > filename part of the code, though exec will only give you the last line of the result and you may need the passthru() function or add an $output var to store every line to an array on the exec function.

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

Sidebar

Related Questions

I have a php script and i want to store some information in RAM.
I have a PHP script which I want to output some text which I'm
I have PHP script, which is requested by user. In this script I want
I want to be able to have a PHP script working in the background.
Hi have some forms that I want to use some basic php validation (regular
If I have some php classes inside a namespace com\test and want to import
I have a PHP page and I want to share some data between pages
I have a similar question to this: PHP session timeout callback? Basically, I want
Say I want a php script the run the function itstime() every hour. Other
I have a php script which can take some GET params. I would like

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.