Link to home
Start Free TrialLog in
Avatar of gaggio
gaggio

asked on

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
Avatar of adam923
adam923

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.
Avatar of ozo
man nohup
Avatar of gaggio

ASKER

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!
Avatar of gaggio

ASKER

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?
use ps u instead of ps to view the process list
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.              
Avatar of gaggio

ASKER

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?


ASKER CERTIFIED SOLUTION
Avatar of adam923
adam923

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gaggio

ASKER

Thanks adam