8400 questions

9885 answers

15679 comments

14155 members

0 votes
341 views 12 comments
by
Dear support. I need my own script automatically start up I put the script line in the rc.local but the script doesn't run! The line to start the scrip is sh /bin/test in the rc.local file before exit 0. How to make it run automatically?

1 Answer

0 votes
by

Hello,

First of all, check if your created script file has set execution permission. To do that, navigate via ssh to the folder where your script is and execute command:

 ls -l

Your output should look something like that:

  • r - refers to read permission.
  • w - refers to write permission.
  • x - refers to execute permission.

If there are none execute permission set, please use this command:

chmod +x test.sh

Secondly, edit /etc/sysupgrade.conf file to preserve your script after upgrades. For example my script is in root folder:

Do not forget to save changes!

And lastly, check if you have specified correct script file path in /etc/rc.local file. My file is in root folder so it looks like this:

Regards.

by

I found the issue in your script.

Your script starts with 

#!/bin/bash 

sleep 5

Change sleep duration to 60 or something longer than 45, because grep function can't find 'Joined LTE network' string until your mobile connection is up. To put it in short, script is executed faster than router connects to network.

Regards.

by
What about then sim switch and modem restart?! These cause connection to network faster then reboot?
by
When you specify your script directory in rc.local file, script automatically starts every time system starts. SIM switch and modem restart is another router features and you need to write your script differently. At least we figured out how to start it, now it is up to you to write correct script using ssh. Sadly, Teltonika staff do not write scripts for customers.

Regards.
by
That’s ok. I know that teltonika doesn’t. But for sim switch  and for modem restart what should the beginning? Does my start of script will not work with sim switch and restart the modem?
by

I suggest to check what strings logread output shows when modem restart and SIM switch events occur and try to use case statement for each scenario. For example:

case word in

   pattern1)
      Statement(s) to be executed if pattern1 matches
      ;;
   pattern2)
      Statement(s) to be executed if pattern2 matches
      ;;
   pattern3)
      Statement(s) to be executed if pattern3 matches
      ;;
   *)
     Default condition to be executed
     ;;