LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Running programs in background via & parameter (https://www.linuxquestions.org/questions/linux-general-1/running-programs-in-background-via-and-parameter-379699/)

dissectional 11-03-2005 03:51 PM

Running programs in background via & parameter
 
Hi,

I use a DYNDNS for my website and use an program called inadyn in order to automaticly verify my IP address with DYNDNS.org every couple minutes as I have a DHCP lease from my ISP. Inadyn when run refreshes this info every couple minutes or so.

I feed inadyn my details via command line parameters, then apply a '&' at the end of the command in order to get it to run in the 'background' - I assume this is a good practice?

Anyway - I have a couple questions regarding this:

1.) Does this continue to run in the background even after I log off? ( via SSH )
2.) Is there anyway to 'call' this program back into the foreground so I can view its output again? After I feed it the & parameter it effectively disappears, albeit continues running. I'd like to get it 'back' when I like to view output if this is possible.

Cheers,

- dissectional

as2100 11-03-2005 04:05 PM

Sure, it'll continue to run as your user even after you log off.
Also, if you want to view any of your backgrounded jobs- use the command 'jobs'. To actually bring up the backgrounded job, use the command 'fg'.

glvgfz 11-03-2005 04:07 PM

1) AFAIK, when you log of most processes get killed. However some processes can detatch themselves and remain after you log off. From what I understand the shell kills the spawned process when you log off, but if the spawned process itself created another process then that does not get killed (correction or confirmation required).

The best way to go about something like this is to use the "GNU Screen" program. It would allow you to detach the terminal from the process and then reattach to it later.

2) To get the program back type in 'fg' (you can also read up about 'bg').

dissectional 11-03-2005 06:47 PM

Cheers guys.

While logged in, I can use the jobs and bg commands to display and also 'mount' the background process again. However - after I log off and back on again, the process continues running, albeit is no longer retrievable via jobs or bg.

Are there any possible solutions to this - or is this a case of tough luck?

glvgfz 11-03-2005 06:50 PM

Quote:

Originally posted by dissectional
Cheers guys.

While logged in, I can use the jobs and bg commands to display and also 'mount' the background process again. However - after I log off and back on again, the process continues running, albeit is no longer retrievable via jobs or bg.

Are there any possible solutions to this - or is this a case of tough luck?

Have you tried "GNU Screen"?

dissectional 11-03-2005 06:58 PM

Sorry, no. Googling it now :)

glvgfz 11-03-2005 07:09 PM

Quote:

Originally posted by dissectional
Sorry, no. Googling it now :)
Here are a couple of tutorials I found helpfull:
http://gentoo-wiki.com/TIP_Using_screen
http://www.kuro5hin.org/story/2004/3/9/16838/14935


All times are GMT -5. The time now is 02:12 PM.