I have two active RPi's. They both have the script:
This script collects data from an accelerometer. I usually start the script on one RPi and then start the script on the other RPi. I run the scripts from both RPi's on one RPi. So that one RPi starts running both its own script and an external script from the other RPi.
I trigger the scripts on each RPi by writing
sudo python adxl345test.py in the console and then pressing Enter. The clocks are synced with PTPd.
The RPi's are networked.
I run both script through one command. Here it is:
pi@Sensor1:~ $ sudo python adxl345test.py & sshpass -p 'password' ssh pi@ip sudo python adxl345test.py
Using sshpass (
sudo apt-get install sshpass) I managed to type the password directly into the command.
Now I want to stop recording data! Normally I would use Ctrl+C but that only works when running a single script on one RPi.
What I'm looking for is to stop the scripts by writing a single command in the console of one RPi. Precision isn't that important at the moment.
I was thinking maybe I could use the following command:
sudo killall python & sshpass -p 'password' ssh pi@ip sudo killall python --- edited WORKS!
This command does stop both RPi from collecting data. On one RPi everything is fine and the data is logged properly however on the other RPi it for some reason doesn't log any data at all even though it was supposed to.
I want to be able to stop both RPi's from collecting data after x seconds.
Turns out the script I was running lacked an important definition. So now the abovementioned killall commando works and the data is also properly kept.