Help using telnet to capture log file with autogenerate timestamp

Hello,

I'm just joining, and looking for a solution to my problem.
I have an app act as server which forward log data using telnet (server). And in my centos machine, act as a telnet client to capture the data, and an application called recorder which readd those log data and to process it then erase it.

I have googled but haven't any luck.

I have try this command using terminal : telnet ip_address port | tee /home/user/$(date +%Y%m%d%H%M%S).txt

My application (recorder) read this text file then erase it.

The problem is, the $(date +%Y%m%d%H%M%S).txt files never created again after erased. The data capture must not stop in anyway, so telnet (client) keep capturing the log.

Is there any shell script to solve my problem?

Thank you before for your help.

=== Eddy ===

You could try emptying the logfile instead of removing it in your application

> logfile

Thank you for your reply.

But I'm a newbie for shell scripting. My Application (recorder) there's no option to emptying the file only.

The step is :

telnet --> create file *.txt
recorder --> get file *.txt --> erase after read

If there telnet capture new data, no *.txt file created.

Is there any solution?

Thank you.

If that file gets erased but is still held open and being written to by tee, it continues to exist in the filesystem. You might be lucky to recapture it with a file system debugger; or, before deleting it, create a second link in a directory.

Have a look at the logrotate command. If I'm correct, you could use it to recreate the logfile and run your application from it.