nsncc
Posts: 2
Joined: Fri Mar 23, 2018 1:00 pm

Running Kplex on reboot

Fri Mar 23, 2018 1:04 pm

I'm running this on a Raspberry Pi I'm using as an AIS receiver. I have followed the documentation but cannot get Kplex to run on start up.

I've tried this:
Created a file called aisstart.sh in /home/pi
Inside the file it says
sudo service kplex start
sudo kplex file:direction=out

Then
chmod -755 /home/pi/aisstart.sh

And added it to rc.local with and without bash

bash /home/pi/aisstart.sh &
#!/bin/sh -e
## rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.
exit 0

I can run the script and rc.local manually but it will not run at start up.

When that didn't work I removed it from rc.local and added it as a cron job using:

@reboot sleep 10 cd/home/pi && /bin/bash aisstart.sh
With and without the sleep.

Is there something simple I am missing or a better way?

User avatar
NathanielJS
Posts: 7
Joined: Sat Feb 24, 2018 12:47 pm

Re: Running Kplex on reboot

Fri Mar 23, 2018 11:56 pm

I would recommend sticking with rc.local rather that cron, as I have had some issues with cron in the past.
bash /home/pi/aisstart.sh &
#!/bin/sh -e
## rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.
exit 0
A reason this may not be working could be you have the line you want to execute "/home/pi/aisstart.sh &" (I would recommend without "bash" at the start) before the shebang (#!/bin/sh -e). Not sure whether I am just misunderstanding, but if it isn't already, try putting it just above "exit 0".

Try this and see if your script runs?

nsncc
Posts: 2
Joined: Fri Mar 23, 2018 1:00 pm

Re: Running Kplex on reboot

Sat Mar 24, 2018 1:20 pm

I made the changes but when I run rc.local I get:

Sudo bash /etc/rc.local
/etc/rc.local: line 13: aisstart.sh: command not found

But I can manually run aisstart.sh from the command line using: sudo bash aisstart.sh and it works.

Here is rc.local, I've tried with and without sudo and bash.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
aisstart.sh &

exit 0

User avatar
NathanielJS
Posts: 7
Joined: Sat Feb 24, 2018 12:47 pm

Re: Running Kplex on reboot

Fri Apr 06, 2018 12:07 pm

nsncc wrote:
Sat Mar 24, 2018 1:20 pm
I made the changes but when I run rc.local I get:
Sudo bash /etc/rc.local
/etc/rc.local: line 13: aisstart.sh: command not found
This is beacuse you have not included the path to assistart.sh, you need to include /home/pi/aisstart.sh. The
/etc/rc.local: line 13: aisstart.sh: command not found
error is because it cannot find the file as it doesn't have the path to it.

Return to “Troubleshooting”