This article is half-done without your Comment! *** Please share your thoughts via Comment ***
Recently, I started to configure few of my DBA shell scripts in Linux Crontab.
Yesterday, I shared an important article on skip the execution of your shell script if it is running already.
If you forget to put the first line of your shell script something like “#!/bin/sh” and bash shell script something like “#!/bin/bash”, you cannot get the name of your running shell script.
It’s called a shebang and tells the parent shell which interpreter should be used to execute the script.
When you are running shell script in Linux, the operating system will look at the first few bytes of the file to decide the format of the program and how to execute it.
If you don’t use “#!/bin/sh” or “#!/bin/bash” on the first line, then the system will treat all the commands in that script as different commands.
So I would suggest please start to add it.
Check below screenshots without #!/bin/bash:
I created sample running.bash file to explain the importance “#!/bin/sh” or “#!/bin/bash”.
Check below screenshots with #!/bin/bash: