0

I am using Raspberry Pi 2 to a telosB base station to collect data from other sensors. I receive (on the terminal) hex data and redirect these incoming data into a python script which will clean and upload to mysql.

Manually (steps i take to do the task:)

  1. source ~/.bashrc
  2. source ~/.tinyos.sh
  3. java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB:telosb | python data-manager.py

I want the raspberry pi2 (running on Rasbian) to do these steps on boot immediately.

I have tried using the update-rc.d method and the crontab method both of which do not work. I think it is because of the arguments in my command that are not going through.

Thanks!

Aloha
  • 7,176
  • 1
  • 29
  • 52

1 Answers1

1

Make one script that does it all (.sh) and setup cron job starting with @reboot instead of times. You probably have to do that on root user (sudo -s). I would rather use full path /home/pi (?) instead of ~ and . instead of source.

To make it persistant, use screen:

sudo apt-get install screen

and add to crontab something like this:

@reboot screen -d my_autorun /home/pi/autorun.sh <-- my_autorun is a name, can be whatever


Edit (2):

Look... you are doing it wrong, and I don't have enough space in comment...

You need to create new file, lets say autorun.sh:

Run cat > autorun.sh paste those lines to it:

cd /home/pi
./home/pi/.bashrc
./home/pi/.tinyos.sh
java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB:telosb | python data-manager.py

... and hit CTRL+C to save it.

Then run: chmod 777 autorun.sh

I think that to be able to listen on that serial port, you need root rights so... run: sudo -s

Next run: crontab -e

And finally add the line @reboot screen -d my_autorun /home/pi/autorun.sh, hit CTRL+X and press Y to save.

That should be it.

Flash Thunder
  • 335
  • 1
  • 4
  • 16