Cannuh
Posts: 3
Joined: Wed Oct 03, 2018 8:52 am

Restarting and continuing a script?

Fri Oct 12, 2018 8:24 am

Hi there,

I have a script in which I need to firstly upgrade the kernel to an older version to run the WiringPi library with my sensor.

Does anybody have an effective way of restarting the script automatically after this? It would just be a convenience to run one file and have it set itself up.

Here is the script below:

Code: Select all

sudo rpi-update 52241088c1da59a359110d39c1875cda56496764
 
[RESTART NEEDED HERE]
 
node -v
curl -sL http://deb.nodesource.com/setup_4.x | sudo -E bash
sudo apt-get -y install nodejs
git clone https://github.com/Azure-Samples/iot-hub-node-raspberrypi-client-app
cd iot-hub-node-raspberrypi-client-app
sudo npm install
nano config.json
	if [ "x$deviceId" = "x" ]; then
    deviceId=RPi
        fi 
sudo node index.js 'DEVICE CONNECTION STRING'
Thanks in advance!

hippy
Posts: 3775
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Restarting and continuing a script?

Fri Oct 12, 2018 11:43 am

I am sure there was a similar post recently which may be worth hunting down.

The basic principle is to store its 'state' ( or 'progress so far' ) in a separate file and/or determine it on the fly so the script only does what it needs to do when run.

It generally won't matter if you configure it to run whenever the Pi starts if it doesn't actually do anything.

DirkS
Posts: 9038
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Restarting and continuing a script?

Fri Oct 12, 2018 1:24 pm

As @hippy says above.
Cannuh wrote:
Fri Oct 12, 2018 8:24 am
I have a script in which I need to firstly upgrade the kernel to an older version to run the WiringPi library with my sensor.
In this situation my first question would be: why do you need to go back to an older kernel to make a sensor work?

Return to “General programming discussion”

Who is online

Users browsing this forum: No registered users and 4 guests