There were often times when I found myself typing the same commands into the terminal on my Raspberry Pi and I with my knowledge of scheduling Python (.py) files to run via CRON I decided to start running my regular terminal commands as scripts.
A BASH executable script is basically a text file saved with the file extension .sh and with a sha-bang line at the very top that reads:
With the file saved close the text editor and open a terminal window. Navigate to the folder containing the file and then type:
chmod +x bash_file_name.sh
Replacing “bash_file_name.sh” with the name of your BASH file’s name.
This command changes the file attributes so that it can be run as an executable. Once executable it can be run via the Terminal by typing: