system() command background process??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hsmcdonald
    New Member
    • Aug 2006
    • 1

    system() command background process??

    Hello all,

    I have a mail function that sends parsed information to an employee distribution list. I was trying to setup a process where the admin can initiate a letter to this list, and basically run it as a background process.

    To provide this functionality, I made a unique php script to handle the mail functions, and I call it from within the main script like something to the effect of:

    [PHP]system("/usr/local/bin/php ./mail.php arg1 arg2 arg3 arg4 >> /tmp/1234log.log");[/PHP]

    It was my understanding that redirecting the output to a file would allow the system command to run in the 'background' like a forked process while the main script completes.

    I can confirm the mail.php script works file.. The /tmp/1234log.log is written fine, but the main script will wait until the mail.php script is completed its task before continuing... This is not what I wanted.

    How do I run this command and allow the script to truly run as a background process while the main script continues to process?

    Thanks in advance..
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, hsmcdonald.

    Add an ampersand at the end of the command string to execute it as a background process:

    Code:
    system("/usr/local/bin/php ./mail.php arg1 arg2 arg3 arg4 >> /tmp/1234log.log [b]&[/b]");

    Comment

    Working...