1

I connect to a dedicated server with SSH. Next I'm trying to execute in php -d max_execution_time[=0] -f index.php . How can I close (even shut down) my local machine, but my php script on remote server should continue working?

3 Answers 3

4

Or with screen http://en.wikipedia.org/wiki/GNU_Screen

screen -A -m -d -S whatever ./yourphpscriptlauncher.sh

The cool +, with:

screen -r whatever

You are again at your script ;)

2
  • +1 for screen. It's useful in other situations too. Alternatively try tmux which is similar to screen Dec 15, 2010 at 14:58
  • i use screen on all my production machines to run all sort of scripts (php and python)
    – s.mihai
    Dec 15, 2010 at 17:02
1

Run your php script like that: ssh user@machine "nohup php -d max_execution_time[=0] -f index.php &"

1
  • 1
    This won't work as written, because when you run a command as an argument to SSH, no TTY is allocated. nohup requires a TTY to detach from. It will work fine if you SSH in, get an interactive shell, and then run the command through nohup, however. The best way to do this non-interactively is probably to submit a command to atd with at now that runs immediately. Dec 15, 2010 at 14:49
0

There are a couple of ways listed here:

http://w-shadow.com/blog/2007/10/16/how-to-run-a-php-script-in-the-background/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .