PDA

View Full Version : Socket Error or nohup error ??



jayasekar
01-28-2010, 06:03 AM
Hi friends,
1. I have created a client socket to receive a data from the server.
2. The data received from the server will be shown in the terminal.
3. i want to run this application as a background and i want to redirect the output to a file. and also i want to run this application even when i log out so i did as given below

nohup myprogram > foo.out 2> foo.err < /dev/null &

4. when i use
$tailf foo.out

Everything is fine. I can view the output

but
i cannot able to view the last data i received.

5. If i run that on terminal, everything is fine. i can able to see the data, even the last one i received.

If i run the same using nohup, i could not able to view the last received data.
Can any one help me out to solve this problem

Thanks in advance

fronty
01-28-2010, 09:09 AM
Do you flush output after printing?

jeffcobb
01-28-2010, 11:53 AM
A cheat would be to use the screen tool...basically run a screen session in a terminal, start your app as if you were running in a terminal and then hit Ctrl-a d (detach session). Then you can log out. When you log into the box again, just run screen -r <reattach to session>; it should auto-attach to the previous session. Note that screen has a lot of powerful tools to offer; see man page...