Results 1 to 3 of 3
I have a bash script that looks like this
bash ./start.sh > ../logs/stdout.log 2> ../logs/stderr.log &
STARTED=$!
echo "$STARTED" >> ../run.pid
wait $STARTED
What does the "&" after ../logs/stderr.log do?
...
- 12-01-2011 #1Just Joined!
- Join Date
- Dec 2011
- Posts
- 1
Bash script help
I have a bash script that looks like this
bash ./start.sh > ../logs/stdout.log 2> ../logs/stderr.log &
STARTED=$!
echo "$STARTED" >> ../run.pid
wait $STARTED
What does the "&" after ../logs/stderr.log do?
Also, why do I need to put "bash" infront of "./start.sh"
Thanks!
- 12-01-2011 #2It puts the start.sh script that executed into the background.What does the "&" after ../logs/stderr.log do?linux user # 503963
- 12-01-2011 #3Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
If the script is not executable, or if it does not have the command line interpreter (bash, in this case) defined in the script, it needs to know how to run it.
To see if it is executable, you can do:
In the below output, the three x's mean the script is executable by owner, group, and all:Code:ls -l start.sh
Assuming you have permissions to do it, you can make a script executable with:Code:-rwxr-xr-x 1 root root 243 Dec 1 2011 myscript.sh
The command line interpreter is probably already defined at the top of the script. For example, a script's command line interpreter could look like one of:Code:chmod +x start.sh
The first two would try to execute the script using bash (or sh, which usually is a symlink to bash) located in the /bin dir. The third will look in your PATH for sh (which is smarter than hard-coding it to /bin), and the 4th will use perl.Code:#!/bin/sh #!/bin/bash #!/usr/bin/env sh #!/usr/bin/perl


Reply With Quote
