0

So basically after a user submits a form I want to create a php background process that checks some stuff with the data they submitted, even if they leave I still want it to be checking but the problem is that I can't get anything to work, I've already looked at all questions related to this on the site and could not find a solution. I did find this code here

exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, "output.txt", "pid.txt"));

but the problem with that is that it only outputs the last thing and it adds some junk in there to.

Output:

sh: line 1: *****: command not found
Mathew
  • 1
  • why don't you echo out this and see if it is the command you expect: echo sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, "output.txt", "pid.txt") – Marius Jul 21 '15 at 18:59
  • It's not working, it's only echoing the command. – Mathew Jul 21 '15 at 19:03
  • 1
    possible duplicate of [Run PHP Task Asynchronously](http://stackoverflow.com/questions/858883/run-php-task-asynchronously) – Joucks Jul 21 '15 at 19:07
  • @Mathew it isn't supposed to work. You're supposed to check if the echoed command is correct or not. – Marius Jul 22 '15 at 14:35

0 Answers0