question

kalito avatar image
kalito asked

How do I make my CerboGX script run at boot?

I got a python script which exports data to PVOutput.org. Using Putty I am able to run the script successfully using the following:

nohup python /data/dbus-pvoutput.py > /data/pvoutput.log &

The trouble happens when the CerboGX is rebooted. I realise the need to have the dbus-pvoutput.py run at startup. What do I need to do. Please be patient as its a miracle that I am even asking this question. I am no coder feel free to treat me as a dummy!

cerbo gx
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

3 Answers
bathnm avatar image
bathnm answered ·

in /data you can create a script called rcS.local. That will be run on every reboot. Also as it is in /data it will not be removed on a system update.

4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

kalito avatar image kalito commented ·

Thanks so much for this. So a line in the script with something like?:

python /data/dbus-pvoutput.py &

0 Likes 0 ·
bathnm avatar image bathnm kalito commented ·

yes that should work.

0 Likes 0 ·
paulo-m avatar image paulo-m commented ·
Just a note based on recent experience - if you add your script as rcS.local it will be called *before* networking, etc. is set up. This can, at least, cause your script to fail and at worst cause the device to hang before SSH is up to let you log in and fix it.


Unless the script really needs to be run early, you'd be better creating a file called rc.local as this is executed late in the boot-up process.

0 Likes 0 ·
Kevin Windrem avatar image Kevin Windrem paulo-m commented ·

I had similar issues and running from rc.local didn't solve them. I ended up running the script in the background, then having the script wait for needed resources (in my case dbus Settings service):

Make the call in rc.local (or rcS.local) this way:

nohup "$script" > /dev/null &


where $script is the path to the script you want executed.

0 Likes 0 ·
Kevin Windrem avatar image
Kevin Windrem answered ·

Another way to do this is to set it up as a "service". Services are managed such that they start at boot and will be restarted should they crash without any user intervention.

You create a "run" script that calls you program and another run script that handles logging (if you want).

You place the run and logging run scripts in a "supervise" directory. You then create a symbolic link to the supervise directory in /service

You would still need to insure that the service is reestablished when a Venus software update occurs. A reinstall script is typically called from /data/rc.local that recreates the symbolic link.


logs are typically stored in /var/log/<the name of your service>

This all sounds complicated, but it's pretty simple to set up. You can use my TankRepeater as an example:

https://github.com/kwindrem/TankRepeater

If you don't need to insure your program is always running, the mechanism bathnm describes is probably simpler for a novice.

Good luck.

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

kalito avatar image kalito commented ·

Thanks this is highly detailed. I wouldn't know which line to start from and where to end!

0 Likes 0 ·
bathnm avatar image bathnm kalito commented ·

take a look in the existing /service directory and create a new service with a similar setup as the others.....


so create a directory /service/pvoutput

create a file in that created directory called run which contains as an example

#!/bin/sh

exec 2>&1

exec /data/dbus-pvoutput.py

If you want some looking, within the /service/pvoutput directory create one call log

Within the log directory create a file called run with something like this

#!/bin/sh

exec multilog t s25000 n4 /var/log/dbus-pvoutoput


At least with this if the process crashes the system will restart it.


0 Likes 0 ·
johanndo avatar image
johanndo answered ·

An alternative would be a cron job, that runs your script on a sheduled time.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic