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
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 ;)
-
+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.mihaiDec 15, 2010 at 17:02
Run your php script like that: ssh user@machine "nohup php -d max_execution_time[=0] -f index.php &"
-
1This 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
withat now
that runs immediately. Dec 15, 2010 at 14:49
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/