Running Shell Script after boot on Raspberry PI
The reason it wasn't working was because the script needed to be run as the user pi.
I changed the code in the rc.local script to this: su - pi -c "bash /home/pi/logon.sh &"
This makes the script run as the user pi and the ampersand is used to make the script run separate to the rc.local script by forking it. (http://hacktux.com/bash/ampersand)
How to run a shell script at startup
The file you put in /etc/init.d/
have to be set to executable with:
chmod +x /etc/init.d/start_my_app
As pointed out by @meetamit, if it still does not run you might have to create a symbolic link to the file in /etc/rc.d/
ln -s /etc/init.d/start_my_app /etc/rc.d/
Please note that on the latest versions of Debian, this will not work as your script will have to be LSB compliant (provide at least the following actions: start, stop, restart, force-reload, and status):
https://wiki.debian.org/LSBInitScripts
As a note, you should always use the absolute path to files in your scripts instead of the relative one, it may solve unexpected issues:
/var/myscripts/start_my_app
Finally, make sure that you included the shebang on top of the file:
#!/bin/sh
Start shell script on Raspberry Pi startup
Make sure the program is executable
chmod +x filename.py
open /etc/rc.local in your editor of choice
sudo nano /etc/rc.local
and add
python /FULL PATH TO SCRITP/filename.py
before the exit
shell script works, but not on boot. [Raspberry pi]
The answer is that contab runs applications as root and therefore the packages have to be installed with sudo
sudo pip install pandas
solved the problem.
Shoutout to CoderMike
Raspberry Pi doesn't run script on autostart
The Problem is that you have to use absolute pathes to the scripts. Using /home/pi/Dektop/s0.sh and so on will work
Related Topics
How to Do Simple Arithmetic in Sed Addresses
Julia: System Image File "Sys.Ji" Not Found
Unix Command to Convert Xls File into Xlsx File
Statically Linked Shared Object? or a Corrupt File
Parsing Result of Diff in Shell Script
Run a .Net Mvc5 Application on Mono
Avoid Copying of Data Between User and Kernel Space and Vice-Versa
How Does Sort Work Out How Much Ram There Is
Bash Script to Compile and Run C++ Program
How to Join Multiple Txt Files into Based on Column
List of Available Wireless Networks with Golang (Under Linux)
Embedded Linux Poll() Returns Constantly
Removing Parts of a String That Contain Digit with Sed/Perl
Where Do Char Device Appear After Cdev_Add() Registers Successfully with Major on 117.
Code Behind Rstudio Server Export Function
Can Not Add New User in Docker Container with Mounted /Etc/Passwd and /Etc/Shadow