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
1,472 views 2 comments
by

Hi,

I have two bash scripts I want to run on start-up, but they are not being executed.

The scripts work fine over SHH and from the CLI.

The Start Script I have is:

# Put your custom commands here that should be executed once

# the system init finished. By default this file does nothing.

# GPS Logger to log coordinates every 60s

/bin/gps-logger.sh

# GPS Updater to update coordinates of the 'Parked' geofence every 60s

/bin/geofence-updater.sh

exit 0

What am I doing wrong?

F/W is RUT9XX_R_00.06.00.4 as anything later than that doesn't have functioning GPS.

Thanks!

by anonymous

I have the same issue, and none of the suggestions provided across the forum are working (add delay, background process, wrap daemon in shell script and so on).

For example:

echo "Before" > /tmp/before
/usr/bin/snmp_exporter.sh &
echo "After" > /tmp/after
exit 0

The 'Before' and 'After' both run, and create their respective files in /tmp/, but the shell script in the middle, does not. That shell script is a simple:

#!/bin/sh

sleep 30
/usr/bin/snmp_exporter --config.file=/etc/snmp/snmp.yml 2>&1

When SSH'ing in, running the same shell script works as expected. Ownership, permissions, bits are all correct.

Putting the raw command itself, into the "Custom Scripts" section, also does not run, which is why I tried wrapping it into a shell script.

The added 'sleep' is there based on a recommendation on another similar thread, where they couldn't get it working either. The sleep didn't help here, and doesn't add any value.

I also tried this form of invocation (again, this works from the shell, does not work in "Custom Scripts")

sh -c /usr/bin/snmp_exporter.sh &

Has anyone figured out why Custom Scripts aren't being run at all?

UPDATE: It turns out I needed a little more magic in the rc.local script to get it working. This now works:

exec 2> /tmp/rc.local.log
exec 1>&2
set -x

/usr/bin/snmp_exporter --config.file=/etc/snmp/snmp.yml 2>&1 &

exit 0

1 Answer

0 votes
by anonymous
Hello,

you need to send them to background using & symbol.

If your scripts do not exit then executed this script hangs on /bin/gps-logger.sh
by
OK, thanks - that works!

Now I have another issue re geofence logic; but I'll open another thread for that.