PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jun 07, 2020 5:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Mon Jul 13, 2009 12:20 pm 
Offline
DevNet Evangelist

Joined: Tue Dec 21, 2004 6:00 pm
Posts: 6267
Location: Winnipeg
I have seen how this is done under Linux by appending a & after the command but I'm using Putty under Windows and I need to detach from the Linux process (PHP script) currently running. This script will need to remain running for several hours and I need to go home before that.

Ctrl+D sounds like the solution but it also sounds like it might stop the script as well. :P

EDIT | It seems the '&' would have worked under Windows too but unfortunately the script is already running via normal invocation so can I change the process while it's running the close the putty window?

Anyone?


Top
 Profile  
 
PostPosted: Mon Jul 13, 2009 3:26 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
Simply fork() a child process :) It will be detached from the current tty.

http://us3.php.net/manual/en/function.pcntl-fork.php

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Mon Jul 13, 2009 3:31 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria
I don't know about PuTTY, but in the linux shell, if you started a process and later decided to detach yourself, just press Ctrl+Z. Then you can control with the program execution.

Detaching with & usually means, that if you close the terminal, the program will be also closed (it's a child process). So forking will be necessary.


Top
 Profile  
 
PostPosted: Mon Jul 13, 2009 3:41 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
And don't forget to redirect STDERR and STDOUT in both (Darhazer's and mine) suggestions.

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Tue Jul 14, 2009 8:02 am 
Offline
DevNet Evangelist

Joined: Tue Dec 21, 2004 6:00 pm
Posts: 6267
Location: Winnipeg
How do I fork a process while using putty?


Top
 Profile  
 
PostPosted: Tue Jul 14, 2009 9:39 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Tue Jul 14, 2009 3:23 pm 
Offline
DevNet Evangelist

Joined: Tue Dec 21, 2004 6:00 pm
Posts: 6267
Location: Winnipeg


Top
 Profile  
 
PostPosted: Tue Jul 14, 2009 6:24 pm 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine


Top
 Profile  
 
PostPosted: Wed Jul 15, 2009 3:15 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
Yes, I should admit that my approach is more for daemonizing processes (i.e. daemons ;) ) and not for "simple" background run.

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Wed Jul 15, 2009 4:40 pm 
Offline
DevNet Resident
User avatar

Joined: Thu May 14, 2009 3:00 pm
Posts: 1011
Location: HellCity, Bulgaria


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group