Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to setup a service to automatically run a python script when the BeagleBone Black (BBB) reboots. These instructions allow you to setup a python script to automatically start when the BeagleBone (running Angstrom linux with systemd) restarts.

Creating a service to startup at BeagleBone Black boot time:

  • Create a shell script such as /usr/bin/

      # this could be any runnable code or shell script, really

Note that the first line is critical.

  • Create a service file in /lib/systemd/myFancy.service such as:

      Description=My Fancy Service
  • Create a symbolic link between your script and a special location under /etc:

      ln -s /lib/systemd/myFancy.service /etc/systemd/system/myFancy.service
  • Make systemd aware of your new service

      systemctl daemon-reload
      systemctl enable myFancy.service
      systemctl start myFancy.service
  • Reboot the BeagleBone Black to see your script in action

  • If you wish to control the service at runtime, you can use systemctl commands:

      systemctl status myFancy.service
      systemctl stop myFancy.service
      systemctl start myFancy.service
      systemctl disable myFancy.service
Copy link

bicubic commented Feb 18, 2014

Hi, I followed this to the letter but get

systemctl enable myFancy.service
Failed to issue method call: No such file or directory

Copy link

Jnesselr commented Sep 10, 2014

I found I had to change /lib/systemd/myFancy.service to /lib/systemd/system/myFancy.service for it to work.

Copy link

ghost commented Nov 30, 2014

Thanks ! I was searching for a long time ! =D

Copy link

atulanandbel commented May 14, 2016

I have followed the steps and created
1: /usr/bin/
2: /lib/systemd/system/atul_start_sr.service
3: ln -s /lib/systemd/system/atul_start_sr.service /etc/systemd/system/atul_start_sr.service
4: systemctl daemon-reload
systemctl enable atul_start_sr.service
systemctl start atul_start_sr.service

1:The scripts "" is working fine.
2: root@beaglebone:/usr/bin# "systemctl list-unit-files" is listing
atul_start_sr.service loaded active running My Auto Start Service

Issue: The service is not able to run the script on reboot.

Copy link

gajjar8055 commented May 24, 2017

Hey, do you have any idea about a script run with virtual environment.

Copy link

prinand01 commented Jun 21, 2021

I have a python script which uses Adafruit_BBIO.GPIO
this works fine when I start the script from the cloud9 environment.
but when I try to schedule it like above, if fails stating import error: no module named Adafruit_BBIO.GPIO as GPIO
and when running from cloud9, it works like a charm ?!?!
I also tried moving it into the autorun folder, but that does not work either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment