benphelps Posted October 20, 2008 Share Posted October 20, 2008 I need to start a PHP file as a process so I can close putty but it still run in the background, any idea how I can do that? I have full root access to the server if it makes any difference. Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/ Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 if you direct output to /dev/null and add a & it should send it to the background and you can close putty: php myscript.php > /dev/null & Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670244 Share on other sites More sharing options...
benphelps Posted October 20, 2008 Author Share Posted October 20, 2008 root@server1 [~]# cd /home/phelps/public_html/botdev root@server1 [/home/phelps/public_html/botdev]# php bot.php > /dev/null & [1] 5044 root@server1 [/home/phelps/public_html/botdev]# If I close putty here, it still shuts the script down. Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670251 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 are you sure the script isn't just finishing? what does the script do? i use that same syntax all the time, and it doesn't shut my scripts down :/ Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670256 Share on other sites More sharing options...
benphelps Posted October 20, 2008 Author Share Posted October 20, 2008 i am sure while (($line = socket_read($socket, 1024, PHP_NORMAL_READ)) !== false) { it doesnt shut down untill I tell it to, its an IRC Bot Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670259 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 so, when you do root@server1 [~]# cd /home/phelps/public_html/botdev root@server1 [/home/phelps/public_html/botdev]# php bot.php > /dev/null & [1] 5044 root@server1 [/home/phelps/public_html/botdev]# it works...but as soon as you close putty it stops working? Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670264 Share on other sites More sharing options...
benphelps Posted October 20, 2008 Author Share Posted October 20, 2008 yeh, it will run forever with the putty window open Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670270 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 very odd...even though it's in the background it must still close the stream. i've never done a background IRC bot before... you can try a cronjob...but you should have the script create a lockfile, that way if another instance opens, you can check for the lock file, telling you if another process of it is already running Link to comment https://forums.phpfreaks.com/topic/129280-start-php-file-as-a-process/#findComment-670277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.