Reputation: 352
I have a RFID module attached to my beaglebone and reading ID tags with a python code. Now, I want my python code to start running in the background directly when I login to my beaglebone without any commands . Just like adding a program to start-up programs in windows. When you login to your windows account, those programs start instantly. Do you have an idea how this can be done?
Regards
Upvotes: 5
Views: 15243
Reputation: 694
Create a new file in /lib/systemd/system/ (rfidreader.service in my example) with content like:
[Unit]
Description=Start Python RFID reader
[Service]
WorkingDirectory=/...Python script path.../
ExecStart=/usr/bin/python rfidreader.py
KillMode=process
[Install]
WantedBy=multi-user.target
Then execute the following command to install the service:
systemctl enable rfidreader.service
To start the service, you can either reboot or execute:
systemctl start rfidreader.service
To check if the service is running and get the latest outputs from the script:
systemctl status rfidreader.service
Upvotes: 17
Reputation: 2300
Take a look at how nodejs application is running on port 3000 of the board and you can implement you module the same way. I think it's part of init process.
http://www.softprayog.in/tutorials/starting-linux-services-with-init-scripts http://www.linuxquestions.org/questions/linux-general-1/how-do-i-automatically-start-a-program-at-start-up-102154/
Upvotes: 0