Creating a service to startup at BeagleBone Black boot time:
-
Create a shell script such as /usr/bin/myFancyBash.sh:
#!/bin/bash # this could be any runnable code or shell script, really /usr/bin/myFancyPython.py
Note that the first line is critical.
-
Create a service file in /lib/systemd/myFancy.service such as:
[Unit] Description=My Fancy Service [Service] Type=simple ExecStart=/usr/bin/myFancyBash.sh [Install] WantedBy=multi-user.target
-
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
I have followed the steps and created
1: /usr/bin/atul_start.sh
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
Observations:
1:The scripts "atul_start.sh" 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.