0

I need to execute a command in linux by using php and it should meet following requirement.

  • should create log file
  • should run as background

I know how to do it separately,

with log file :

shell_exec("command 1>log 2>&1");

as background:

shell_exec("command /dev/null 2>&1 &");

My question is how to do it together ?

1
  • 1
    Actually your second example does not run the command "in background" by which people typically mean "without the calling process to wait for it to finish". You need to detach the controlling console for that: shell_exec("nohup command /dev/null 2>&1 &"); Commented Mar 1, 2014 at 8:55

1 Answer 1

1
shell_exec("command 1>log 2>&1 &");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.