By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,930 Members | 1,424 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,930 IT Pros & Developers. It's quick & easy.

system() command background process??

P: 1
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..
Sep 8 '06 #1
Share this Question
Share on Google+
1 Reply


pbmods
Expert 5K+
P: 5,821
Heya, hsmcdonald.

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

Expand|Select|Wrap|Line Numbers
  1. system("/usr/local/bin/php ./mail.php arg1 arg2 arg3 arg4 >> /tmp/1234log.log &");
  2.  
Jan 24 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.