Continuous nc data acquisition fails ocassionally


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Continuous nc data acquisition fails ocassionally
# 15  
Old 06-02-2018
-I've realized that the script only stops and 5:05 and 17:05 so I thought that maybe was a cron job in the server but I could not fin anything. I tried the same in my local area network and the same happens so maybe the data streams is doing something weird and that times.

-I use vim to take a look to the files when this happens, to see if theres any special mark. I found that at the end of the file there are several trailing characters:
Image

·Maybe this is causing any problem to the awk sentence?
·Any clues of waht is happening or how to solve it?

All the best
# 16  
Old 06-27-2018
I know what is happening hopefully you can help me now:

-Two times a day the receiver from where I'm getting the data stops sending for a couple of seconds due to an internal cron job.

-Because of this my entire all the process of getting AIS sentences stops:
Code:
nc -ul -p 56045 -q -1 | awk -F: 'NF > 1 {print strftime("%d-%m-%Y %H:%M:%S"),$0;fflush();  }' > awk.txt 2>&1 &


but I'm listening forever in my nc sentences, so what is happening¿?

All the best
# 17  
Old 06-27-2018
Instead of why? how about using tail -f which is meant to solve this problem.
Code:
nc -ul -p 56045 -q -1 | tail -f | awk -F: 'NF > 1 {print strftime("%d-%m-%Y %H:%M:%S"),$0;fflush();  }' > awk.txt 2>&1 &

What you need to consider, if you do not like tail, is to develop some kind of daemon - usually written in C. You have an attached child process that leaves the parent there forever. If I understand what you have there.

PS: fflush() on every line forces disk I/O instead of buffered I/O. Since nc can produce an endless stream of data this change might help.

Last edited by jim mcnamara; 06-27-2018 at 10:42 AM..
# 18  
Old 06-27-2018
Thanks a lot Jim!

I will try with tail then and see what happens

About fflush(), I'm already using it inside my awk sentence do you mean that It better to avoid using it¿?

All the best
# 19  
Old 06-27-2018
Can you please try the bsd version Smilie
It should take little time and effort.
This was a well intent suggestion before, since i had issues with gnu nc while experimenting with go and stuff.

Similar issues as you describe here.

I did not debug further.
Only switched version which resulted in expected behavior..

Regards
Peasant.
# 20  
Old 06-27-2018
Dear Jim,

your adding of tail -f is not working, the file its not created and nothing else happens..

Dear Peasant,

I can't try that in the server because I dont have that privilegies but I did that on my laptop with no changes...

All the best
# 21  
Old 06-27-2018
a closer look at what the cron cron job is doing could shed some light here.
I suspect it could be doing something to disrupt the sending process.

What is the purpose of the cron job that runs at these times?

If it's doing something like a backup for example, it could quiesce or stop services like databases, etc that the sender relies on. Log rotation jobs could stop and re-start the sender causing a loss of the open socket.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Continuous for loop

Hi All, Please help ***************** a=100 and run for loop that will minus 30 from 100 an will display value run loop will run till display value will be 0 ***************** Thanking you (1 Reply)
Discussion started by: Praful Pednekar
1 Replies

2. Shell Programming and Scripting

Continuous Copying from a directory to another.

Hello Folks, Looking for a script, where i can check for the existing of the files in a directory and copying to another. How can i achieve it in loop for over period of time. whatever files comes into the folder copied in another without duplicate and should be continuous loop. ... (8 Replies)
Discussion started by: sadique.manzar
8 Replies

3. UNIX for Dummies Questions & Answers

Extracting data between continuous non empty xml tags

Hi, I need help in extracting only the phone numbers between the continuous non empty xml tags in unix. I searched through a lot of forum but i did not get exact result for my query. Please help Given below is the sample pipe delimited file. I have a lot of tags before and after... (6 Replies)
Discussion started by: zen01234
6 Replies

4. Shell Programming and Scripting

Continuous checking of a file

I have a requirement like this... I want to go to a particular server for which i have acess .I want to do a ssh to that server from one server and check if a file is theer or not..and i need the script to chcek continuosly till it finds the file.When it finds the file i want it to come out... (9 Replies)
Discussion started by: kanta_bhakti
9 Replies

5. UNIX for Advanced & Expert Users

Need info regarding CDP - continuous data protection

HI frnds, i am going to work on CDP(continuous data protection),does any one of them have any idea reg CDP ... any docs or Links...might be helpful to me in understanding it.... (1 Reply)
Discussion started by: deep
1 Replies
Login or Register to Ask a Question