Putty and starting PHP scripts via shell

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
visionmaster
Forum Contributor
Posts: 139
Joined: Wed Jul 14, 2004 4:06 am

Putty and starting PHP scripts via shell

Post by visionmaster »

Hello together,

Starting a PHP script using putty, e.g. /opt/lampp/bin/php my_script.php & and closing this putty session, unfortunately closes the started script.
How can I avoid that, since I want to run a few scripts on different internal webservers, but don't want to leave the shell windows open?

Thanks for your help,
visionmaster
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Code: Select all

/opt/lampp/bin/php my_script.php >/dev/null 2>&1 &
visionmaster
Forum Contributor
Posts: 139
Joined: Wed Jul 14, 2004 4:06 am

Post by visionmaster »

redmonkey wrote:

Code: Select all

/opt/lampp/bin/php my_script.php >/dev/null 2>&1 &
Thanks for your response. That doesn't work, closing the ssh windows also shuts down the running script.

The command "screen" seems to be the thing I'm looking for.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You could put the php script in a cron job.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
cggreer
Forum Newbie
Posts: 14
Joined: Mon Jul 21, 2003 6:39 am

Post by cggreer »

You can force the process to continue executing after you logout or close the terminal windor by prefixing your command with the nohup statement and executing it in the background:

Code: Select all

nohup command &
Any output from the process which would normally be sent to the terminal is written to nohup.out in the directory the process was launched from.

Check out http://wiki.linuxquestions.org/wiki/Nohup for more info about nohup.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I usually run all my programs in screen.. This way i can attach and re-attach anytime i want ;) (Handy for irc etc too :))
Post Reply