Yuan Fen
Yuan Fen

Reputation: 153

Execute shell command run php in background

I run a php script through shell using the following:

php script.php

How do I type this command in order to run it on the background and also log the output to a file?

I've tried

php script.php 2>&1 > out.log

But once I close putty, the script stopped.

Upvotes: 2

Views: 2478

Answers (3)

donald123
donald123

Reputation: 5749

you can use nohup (no hang up)

  nohup php script.php 2>&1 > out.log

or you use cron or at to run your script in background

Upvotes: 2

Piotr Olaszewski
Piotr Olaszewski

Reputation: 6224

Try call like this:

php script.php 2>&1 > out.log &

Upvotes: 0

Bart Friederichs
Bart Friederichs

Reputation: 33573

Add a & after the command.

Upvotes: 0

Related Questions