You are here

linux

Launching Simultaneous Processes

A student in my course is looking for a way to launch processes simultaneously on multiple raspberry pi computers. It was not immediately apparent to me how to do this, but the first thing that came to mind was "at" which lets you schedule a process to launch "at" a particular time. To test, I set up two rasberry pis: mahiro and poneo.

I wrote a python script:

----now.py----
#! /usr/bin/python3
import time
ns = time.time_ns()
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f'"{timestamp}",{ns}')
file = open("/home/pi/attest/time.txt","a")
file.write(f'"{timestamp}",{ns}\n')
file.close()

a shell script to invoke it:

----now.sh----
#! /bin/sh
/usr/bin/python3 /home/pi/attest/now.py

I put that on two pis, made sure the timezone was set to eastern, then used a script on my laptop to invoke it:

----attest.sh----
#! /bin/bash
ssh pi@mahiro at -f /home/pi/attest/now.sh "$1 today"
ssh pi@poneo at -f /home/pi/attest/now.sh "$1 today"

So, this uses ssh to talk to the pis and runs the "at" command to run the bash script at a particular time today. Then I tell the script what time to run, e.g.
./attest.sh 10:30am

And then the script invokes the processes on the same second on both pis. Here are the results:
----poneo----
"2020-11-10 10:22:00",1605021720479176213
"2020-11-10 10:29:00",1605022140756637058
"2020-11-10 10:30:01",1605022201055563711
"2020-11-10 10:31:00",1605022260561006216
----mahiro----
"2020-11-10 10:22:00",1605021720479176213
"2020-11-10 10:29:00",1605022140295769154
"2020-11-10 10:30:00",1605022200649709852
"2020-11-10 10:31:00",1605022260111136737

The first time, it worked PERFECTLY -- the nanosecond time readings are identical. In the other ones, they're not even always within the same second. But pretty close.

So, now we need to decide whether this is close enough or if we need to find another approach.

System76 Meerkat

For the past four years, I've been using a linux box for my primary "at home" computer. That year, I taught a class on building a computer with the kids at North Star. When North Star didn't want to use it, I reclaimed it and set it up at home. It's been a great little computer. But it was always underpowered -- I never really intended to run it with a graphical operating system. And it has been getting long in the tooth.

I decided to buy a System 76 Meerkat. It's based on the Intel NUC. I thought about trying put one together myself, then I looked them up at NewEgg. Ugh. It was nice to just flip among a handful of options with System76 and get a device with Ubuntu already installed and know that someone else had taken care of whether or not things would be supported.

So far, I'm very happy. The unboxing experience was pleasant. The setup was smooth. The switch from Ubuntu LTS 12.04 to 16.04 has been seamless.

The big test was migrating my wife's account.

I still have to migrate my own data. And TT-RSS. And then do the networking jiggery pokery to have the new server take over for the old one. But so far, so good.

The "Red Hat" allegory

I was chatting with a former student today and was reminded of a funny story that is probably relevant to the OLPC story. When Wayan says "back in this amazing place I like to call 'reality'" I'm reminded of the time I wore my red hat to Austin.

Several years ago, my brother Phil bought me an official RedHat red hat for Christmas. At the time, I was using RedHat quite a bit and I've worn it proudly for years. I've probably received more compliments for that hat than for anything else I've ever owned or done in my whole life. On this one trip to Austin, while in airports, etc, I received many positive comments and three serious offer to buy the hat off my head.

Any time anyone would comment on the hat, I would mention that it was an official "RedHat" red hat. In Amherst, a fair number of people would know what RedHat was and, if they didn't, they would at least have heard of linux. Not so on the airports between here and Austin. Not one of the people I spoke to while travelling had ever heard of either RedHat or Linux. It was a valuable lesson to me to remind me what an insular world we netwits actually live in.

Subscribe to RSS - linux