Want a program running after logout

Hi.
I'm a user on a Linux machine. When I want to use the
machine, I have to log on and when I'm done I logout.
This is probably a question I could have asked on the Unix
panel also, BTW.

Now, here's my problem: I'd like to have a program running
in the background of the machine AFTER I have logged out.
More precisely, this program would listen on a socket and reply
to some queries.
How does that work?
I guess that there should be a method to do that but I have
not found any information about it.

Do I need to have root access to get that working?

Thanks for help.
Gaggio
LVL 1
gaggioAsked:
Who is Participating?
 
adam923Connect With a Mentor Commented:
see the manpage except i put above... commands that are executed using the & don't respond to the HUP signal but don't have terminal redirection like "nohup" provides... for what you're trying to do there's really no difference.  
0
 
adam923Commented:
with most programs you should be able to run them from a command prompt with a & at the end of the line to run in the background.  Once it starts running the shell will give you a number that's the "process id".  You can then log out if you'd like and the program will terminate whenever its done, or if you've programmed it to run forever just kill it with the kill command followed by the process id number.
0
 
ozoCommented:
man nohup
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
gaggioAuthor Commented:
adam, what you said does not work.
I have a test program that is just a infinite loop.
When I start it and then logout it is killed automatically.
I'd like something that is still running when I log back in!
0
 
gaggioAuthor Commented:
ozo, nohup is probably the right command to use, but
it does not work: when I log on to a Linux machine at
my university, run the program "nohupped", logout and
log back in, the program is not in the process list anymore.

The man/info pages for nohup are read pretty quick: there
are only two options.

Any hint?
Is there another way?
0
 
adam923Commented:
use ps u instead of ps to view the process list
0
 
adam923Commented:
From the man page... this is why my suggestion worked for me, maybe you aren't using csh? also, i tried this on solaris, not linux

 The C-shell ( csh(1)) has a  built-in  command  nohup   that
     provides  immunity from SIGHUP, but does not redirect output
     to nohup.out. Commands executed with `&'  are  automatically
     immune to HUP signals while in the background.              
0
 
gaggioAuthor Commented:
Ok adam, you are right: if I use ps -u mylogin I actually
still have the process running in the background, when
I simply use the '&' at the end of the line.

Hmmm, I knew about & but I didn't know that it was keeping
the prog running even if you logout!

Ok, so, before giving away the points (and to be fair to
Ozo), here is what will determine the winner:

What is the difference between '&' and nohup?


0
 
gaggioAuthor Commented:
Thanks adam
0
All Courses

From novice to tech pro — start learning today.