How to automatically run a Python script after bootup?
-
How do I get a Python script to run automatically on start-up or reboot? My immediate need is to turn off the LEDs on the expansion dock, and I've written and tested a Python script to do just that, but it would be nice to know how to do this in the general sense. I've tried putting
python /root/myPythonScript.py
into a file called rc.local, and installing it in /etc/init.d, but it's not executing on startup or reboot. Is there a different way to do this for the Onion?
-
@Jeff-Verive What works for me is:
-
To run something when the Omega boots, put the commands in /etc/rc.local (not /etc/init.d/rc,local as you suggest)
-
To run something only when you log on to the Omega, put the commands in /etc/profile
Note that both these files (/etc/rc.local and /etc/profile) already exist and so you should add your commands by editing the existing contents.
-
-
So just to be clear, crontab does not appear to work on the onion. Perhaps that is something that can be removed or is this perhaps a bug?
-
@Stephen-Tunney Not sure why you should think crontabs doesn't work. It is standardly installed and is used as part of the standard set up for which it is used to run wifisaint used to check on wifi AP setup (see: https://github.com/OnionIoT/wifisaint)
The crontab info used is held in /etc/crontabs/root which is in the format as described in http://crontab.org/
Just add your own line to /etc/crontabs/root and either reboot or run crontab /etc/crontabs/root
-
@Kit-Bishop Thanks for the help with Cron!
-
sometime rc.local is not executable out of the box.