FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
311 views 2 comments
by anonymous

All,

I have put script on the router to ping an external host. So, the external host can uses that IP address to connect to the router. also after an IP renewal.

I noticed that after some hours (days) the router does not send any message to the selected host and connection between router and host get lost. What I noticed are two things:

  1. Script doesn't run anymore
  2. when doing a ps | grep <script name> I see that the script is running but does not send anything.  When I start the script manually the host is receiving it again.

The script should run continuous to echo some text to the remote host on a specific port.

 Below the script:

while true

do

 echo -n "<some tekst>" | nc <remote host> 8888

 sleep 10

done

FW Version is: RUT2_R_00.07.01.2

1 Answer

0 votes
by anonymous

Hi,

there may be many reasons why the script stops working. 

But you can solve the problem by adding a script to cron and configuring its launch, for example, every 5 - 10 - 30 seconds. You can set up the period correctly using special calculators. For example this https://www.freeformatter.com/cron-expression-generator-quartz.html. Information on setting up Cron on the router can be found in the wiki - https://wiki.teltonika-networks.com/view/Crontabs

Best regards.

by anonymous

In the RUT240 Cron only the following options are valid:

minute hour day of month month day of week

So, you can not execute a script every x second via the crontab .

by anonymous
Hi, as it turned out, cron really works with whole minutes at least. I can offer a not very elegant, but I think an effective way.

Create 6 scripts and run them every minute via cron, but with a difference of 10 seconds. Naturally, first remove the loop from the script itself.

I did like this:

* * * * * /root/script.sh

* * * * * sleep 10; /root/script2.sh

* * * * * sleep 20; /root/script3.sh

scripts start at the same time, but execution takes place at different times.

Best regards.