Ubuntu SSH behavior

Hi Chaps,

I'm about a 3/10 on Linux skill wise,

Quick question, I'm on Ubuntu 12.04.3, I'm running it on my Linode,

Anyway, I am basically running two php scripts to monitor a database and send push notifications for my iPhone app.

So I log in via ssh, kick off the php scripts and use an ampersands to put the task in the background, my question is when I terminate my ssh session, the two php tasks continue to run in the back ground, (I know this because push notifications continue to arrive), however a linux 'expert' buddy of mine tells me this can't be the case and I need to use 'screen' or 'tmux'.

But the evidence is that the processes don't end when I end the ssh session (which was a root session for what it's worth).

The scripts are pretty simple PHP e.g.

Monitor a web feed

Loop through an array

Write to local database

So nothing special, I just start them with "php script.php&"

So I'm not daemonizing to my knowledge…

This is really strange,

So I login last night at home (after a week or so of setting up a LAMP stack and configuring everything).

I just use my Mac running OS X, open terminal and type ssh root@xxx.xxx.xxx.xxx

I enter password and i'm in, kick off the php scripts.

I shutdown my Mac, and the push notifications are working on my iOS app (which can literally only happen if the php scripts are running).

When I log in from work this morning using a non root user 'user1' I type, 'who' and can only see myself as logged in,

Then when I type 'PS -A | grep -i php'

I see the two php processes running like this:

****6363 ? 00:00:02 php

6364 ? 00:00:02 php****

infact nearly all processes in PS have ? as tty,

does this sound normal, any idea what's going on?

Thanks for your help! - I'm happy with what's happening, but wanted to check that these processes won't just die at some point,

so is my buddy right?

5 Replies

What does kicking off the scripts mean? How do you do it?

-Tim

Hi my friend,

I literally just type "php script.php&"

at the prompt.

Here is one of the scripts:

http://tny.cz/52b68ead

For my own curiosity, do you know what the ampersand does?

-Tim

No fair looking at the source code you posted!

@theckman, Yes, it makes the job in the background right? same as doing a ctrl-Z and bg.

It can be brought to foreground by fg, that's it right?

@derfy, What do you mean no fair? :D

So are my jobs going to be ok running in the background, it seems my ssh session when disconnected does NOT end jobs I start with &.

I am happy with this, but other ppl online and friends say that the jobs should end when the ssh session ends??

Thanks again

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct