Can I redirect output to a log file and background a process at the same time?
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to the background, like so:
java -jar myProgram.jar 2>$1 > output.log
jobs
[CTRL-Z]
bg 1
bash shell shell-script
add a comment |
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to the background, like so:
java -jar myProgram.jar 2>$1 > output.log
jobs
[CTRL-Z]
bg 1
bash shell shell-script
1
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.2>$1
is probably supposed to be2>&1
.
– Patrick
May 3 '13 at 0:10
add a comment |
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to the background, like so:
java -jar myProgram.jar 2>$1 > output.log
jobs
[CTRL-Z]
bg 1
bash shell shell-script
Can I redirect output to a log file and background a process at the same time?
In other words, can I do something like this?
nohup java -jar myProgram.jar 2>&1 > output.log &
Or, is that not a legal command? Or, do I need to manually move it to the background, like so:
java -jar myProgram.jar 2>$1 > output.log
jobs
[CTRL-Z]
bg 1
bash shell shell-script
bash shell shell-script
edited Jul 10 '17 at 22:35
Dagrooms
1054
1054
asked May 2 '13 at 23:56
djangofandjangofan
9752917
9752917
1
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.2>$1
is probably supposed to be2>&1
.
– Patrick
May 3 '13 at 0:10
add a comment |
1
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.2>$1
is probably supposed to be2>&1
.
– Patrick
May 3 '13 at 0:10
1
1
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.
2>$1
is probably supposed to be 2>&1
.– Patrick
May 3 '13 at 0:10
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.
2>$1
is probably supposed to be 2>&1
.– Patrick
May 3 '13 at 0:10
add a comment |
5 Answers
5
active
oldest
votes
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to go, and then send stderr to the address stdout is at
some_cmd > some_file 2>&1 &
and then you could throw the & on to send it to the background. Jobs can be accessed with the jobs
command. jobs
will show you the running jobs, and number them. You could then talk about the jobs using a % followed by the number like kill %1
or so.
Also, without the & on the end you can suspend the command with Ctrlz, use the bg
command to put it in the background and fg
to bring it back to the foreground. In combination with the jobs
command, this is powerful.
to clarify the above part about the order you write the commands. Suppose stderr is address 1002, stdout is address 1001, and the file is 1008. The command reads left to right, so the first thing it sees in yours is 2>&1
which moves stderr to the address 1001, it then sees > file
which moves stdout to 1008, but keeps stderr at 1001. It does not pull everything pointing at 1001 and move it to 1008, but simply references stdout and moves it to the file.
The other way around, it moves stdout to 1008, and then moves stderr to the point that stdout is pointing to, 1008 as well. This way both can point to the single file.
can't seem to capture the pid after this though with$!
– chovy
Dec 2 '15 at 8:21
6
Also worth noting: you can use&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting2>&1
in the wrong place in your command line.
– Dan
Jan 4 '17 at 21:33
add a comment |
Stopping with <Ctrl+Z>
and continuing in the background with bg
is equivalent to execute with &
at the end of the command.
So, for run in the background and redirect output:
java -jar myProgram.jar 2> errorOutput.log > output.log &
If you also need that this command does not die when you leave the terminal, then you should use nohup
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
nohup doesn't execute the command in the background, you have to explicitly append&
– jlliagre
Jun 3 '13 at 22:34
2
After you moved a process to the background withbg
, you can detach it from your session by runningdisown
, which makes that the process doesn't die when you close the terminal.
– Koen.
Dec 30 '16 at 15:09
add a comment |
java -jar myProgram.jar &> output.log &
Note that the &>
directs both stdout and stderr to output.log
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
add a comment |
Instead of using nohup you can use screen. You can view the status of the program in real time. you can even log all the output to a file. It is useful when you access the server via ssh where you get logged out due to poor connection or inactivity. After logging in you can continue the work from where you left. refer this and this to know in detail.
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
add a comment |
The tee
command is pretty prevalent too.
nohup java -jar myProgram.jar | tee output.log &
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f74520%2fcan-i-redirect-output-to-a-log-file-and-background-a-process-at-the-same-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to go, and then send stderr to the address stdout is at
some_cmd > some_file 2>&1 &
and then you could throw the & on to send it to the background. Jobs can be accessed with the jobs
command. jobs
will show you the running jobs, and number them. You could then talk about the jobs using a % followed by the number like kill %1
or so.
Also, without the & on the end you can suspend the command with Ctrlz, use the bg
command to put it in the background and fg
to bring it back to the foreground. In combination with the jobs
command, this is powerful.
to clarify the above part about the order you write the commands. Suppose stderr is address 1002, stdout is address 1001, and the file is 1008. The command reads left to right, so the first thing it sees in yours is 2>&1
which moves stderr to the address 1001, it then sees > file
which moves stdout to 1008, but keeps stderr at 1001. It does not pull everything pointing at 1001 and move it to 1008, but simply references stdout and moves it to the file.
The other way around, it moves stdout to 1008, and then moves stderr to the point that stdout is pointing to, 1008 as well. This way both can point to the single file.
can't seem to capture the pid after this though with$!
– chovy
Dec 2 '15 at 8:21
6
Also worth noting: you can use&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting2>&1
in the wrong place in your command line.
– Dan
Jan 4 '17 at 21:33
add a comment |
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to go, and then send stderr to the address stdout is at
some_cmd > some_file 2>&1 &
and then you could throw the & on to send it to the background. Jobs can be accessed with the jobs
command. jobs
will show you the running jobs, and number them. You could then talk about the jobs using a % followed by the number like kill %1
or so.
Also, without the & on the end you can suspend the command with Ctrlz, use the bg
command to put it in the background and fg
to bring it back to the foreground. In combination with the jobs
command, this is powerful.
to clarify the above part about the order you write the commands. Suppose stderr is address 1002, stdout is address 1001, and the file is 1008. The command reads left to right, so the first thing it sees in yours is 2>&1
which moves stderr to the address 1001, it then sees > file
which moves stdout to 1008, but keeps stderr at 1001. It does not pull everything pointing at 1001 and move it to 1008, but simply references stdout and moves it to the file.
The other way around, it moves stdout to 1008, and then moves stderr to the point that stdout is pointing to, 1008 as well. This way both can point to the single file.
can't seem to capture the pid after this though with$!
– chovy
Dec 2 '15 at 8:21
6
Also worth noting: you can use&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting2>&1
in the wrong place in your command line.
– Dan
Jan 4 '17 at 21:33
add a comment |
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to go, and then send stderr to the address stdout is at
some_cmd > some_file 2>&1 &
and then you could throw the & on to send it to the background. Jobs can be accessed with the jobs
command. jobs
will show you the running jobs, and number them. You could then talk about the jobs using a % followed by the number like kill %1
or so.
Also, without the & on the end you can suspend the command with Ctrlz, use the bg
command to put it in the background and fg
to bring it back to the foreground. In combination with the jobs
command, this is powerful.
to clarify the above part about the order you write the commands. Suppose stderr is address 1002, stdout is address 1001, and the file is 1008. The command reads left to right, so the first thing it sees in yours is 2>&1
which moves stderr to the address 1001, it then sees > file
which moves stdout to 1008, but keeps stderr at 1001. It does not pull everything pointing at 1001 and move it to 1008, but simply references stdout and moves it to the file.
The other way around, it moves stdout to 1008, and then moves stderr to the point that stdout is pointing to, 1008 as well. This way both can point to the single file.
One problem with your first command is that you redirect stderr to where stdout is (if you changed the $ to a & as suggested in the comment) and then, you redirected stdout to some log file, but that does not pull along the redirected stderr. You must do it in the other order, first send stdout to where you want it to go, and then send stderr to the address stdout is at
some_cmd > some_file 2>&1 &
and then you could throw the & on to send it to the background. Jobs can be accessed with the jobs
command. jobs
will show you the running jobs, and number them. You could then talk about the jobs using a % followed by the number like kill %1
or so.
Also, without the & on the end you can suspend the command with Ctrlz, use the bg
command to put it in the background and fg
to bring it back to the foreground. In combination with the jobs
command, this is powerful.
to clarify the above part about the order you write the commands. Suppose stderr is address 1002, stdout is address 1001, and the file is 1008. The command reads left to right, so the first thing it sees in yours is 2>&1
which moves stderr to the address 1001, it then sees > file
which moves stdout to 1008, but keeps stderr at 1001. It does not pull everything pointing at 1001 and move it to 1008, but simply references stdout and moves it to the file.
The other way around, it moves stdout to 1008, and then moves stderr to the point that stdout is pointing to, 1008 as well. This way both can point to the single file.
edited Mar 9 '15 at 13:55
spinup
35117
35117
answered Dec 26 '13 at 8:04
Jacob MinshallJacob Minshall
2,57611210
2,57611210
can't seem to capture the pid after this though with$!
– chovy
Dec 2 '15 at 8:21
6
Also worth noting: you can use&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting2>&1
in the wrong place in your command line.
– Dan
Jan 4 '17 at 21:33
add a comment |
can't seem to capture the pid after this though with$!
– chovy
Dec 2 '15 at 8:21
6
Also worth noting: you can use&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting2>&1
in the wrong place in your command line.
– Dan
Jan 4 '17 at 21:33
can't seem to capture the pid after this though with
$!
– chovy
Dec 2 '15 at 8:21
can't seem to capture the pid after this though with
$!
– chovy
Dec 2 '15 at 8:21
6
6
Also worth noting: you can use
&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting 2>&1
in the wrong place in your command line.– Dan
Jan 4 '17 at 21:33
Also worth noting: you can use
&> file.out
to redirect both stdin and stdout to an output file, which cuts down on the possibility of a mistake with putting 2>&1
in the wrong place in your command line.– Dan
Jan 4 '17 at 21:33
add a comment |
Stopping with <Ctrl+Z>
and continuing in the background with bg
is equivalent to execute with &
at the end of the command.
So, for run in the background and redirect output:
java -jar myProgram.jar 2> errorOutput.log > output.log &
If you also need that this command does not die when you leave the terminal, then you should use nohup
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
nohup doesn't execute the command in the background, you have to explicitly append&
– jlliagre
Jun 3 '13 at 22:34
2
After you moved a process to the background withbg
, you can detach it from your session by runningdisown
, which makes that the process doesn't die when you close the terminal.
– Koen.
Dec 30 '16 at 15:09
add a comment |
Stopping with <Ctrl+Z>
and continuing in the background with bg
is equivalent to execute with &
at the end of the command.
So, for run in the background and redirect output:
java -jar myProgram.jar 2> errorOutput.log > output.log &
If you also need that this command does not die when you leave the terminal, then you should use nohup
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
nohup doesn't execute the command in the background, you have to explicitly append&
– jlliagre
Jun 3 '13 at 22:34
2
After you moved a process to the background withbg
, you can detach it from your session by runningdisown
, which makes that the process doesn't die when you close the terminal.
– Koen.
Dec 30 '16 at 15:09
add a comment |
Stopping with <Ctrl+Z>
and continuing in the background with bg
is equivalent to execute with &
at the end of the command.
So, for run in the background and redirect output:
java -jar myProgram.jar 2> errorOutput.log > output.log &
If you also need that this command does not die when you leave the terminal, then you should use nohup
Stopping with <Ctrl+Z>
and continuing in the background with bg
is equivalent to execute with &
at the end of the command.
So, for run in the background and redirect output:
java -jar myProgram.jar 2> errorOutput.log > output.log &
If you also need that this command does not die when you leave the terminal, then you should use nohup
edited Jul 31 '15 at 18:27
answered May 3 '13 at 0:56
RSFalcon7RSFalcon7
2,39732146
2,39732146
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
nohup doesn't execute the command in the background, you have to explicitly append&
– jlliagre
Jun 3 '13 at 22:34
2
After you moved a process to the background withbg
, you can detach it from your session by runningdisown
, which makes that the process doesn't die when you close the terminal.
– Koen.
Dec 30 '16 at 15:09
add a comment |
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
nohup doesn't execute the command in the background, you have to explicitly append&
– jlliagre
Jun 3 '13 at 22:34
2
After you moved a process to the background withbg
, you can detach it from your session by runningdisown
, which makes that the process doesn't die when you close the terminal.
– Koen.
Dec 30 '16 at 15:09
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
Oh I see. You are saying the appended '&' char is redundant?
– djangofan
May 7 '13 at 20:32
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
I just quote the manpage. Since nohup will execute the command in the background anyway, seems redundant to execute nohup itself in the background
– RSFalcon7
May 8 '13 at 0:31
9
9
nohup doesn't execute the command in the background, you have to explicitly append
&
– jlliagre
Jun 3 '13 at 22:34
nohup doesn't execute the command in the background, you have to explicitly append
&
– jlliagre
Jun 3 '13 at 22:34
2
2
After you moved a process to the background with
bg
, you can detach it from your session by running disown
, which makes that the process doesn't die when you close the terminal.– Koen.
Dec 30 '16 at 15:09
After you moved a process to the background with
bg
, you can detach it from your session by running disown
, which makes that the process doesn't die when you close the terminal.– Koen.
Dec 30 '16 at 15:09
add a comment |
java -jar myProgram.jar &> output.log &
Note that the &>
directs both stdout and stderr to output.log
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
add a comment |
java -jar myProgram.jar &> output.log &
Note that the &>
directs both stdout and stderr to output.log
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
add a comment |
java -jar myProgram.jar &> output.log &
Note that the &>
directs both stdout and stderr to output.log
java -jar myProgram.jar &> output.log &
Note that the &>
directs both stdout and stderr to output.log
edited Nov 26 '18 at 15:12
Sam Redway
1034
1034
answered Sep 8 '16 at 9:47
Abhinav BhatiaAbhinav Bhatia
6111
6111
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
add a comment |
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
3
3
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
A one-line explanation will make the answer complete.
– anaik
Jun 7 '17 at 6:12
2
2
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
@abhisheknaik96 it runs the jar file and redirects both stdin and stderr to output.log and make it background process.
– P Pang
Oct 26 '17 at 6:48
add a comment |
Instead of using nohup you can use screen. You can view the status of the program in real time. you can even log all the output to a file. It is useful when you access the server via ssh where you get logged out due to poor connection or inactivity. After logging in you can continue the work from where you left. refer this and this to know in detail.
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
add a comment |
Instead of using nohup you can use screen. You can view the status of the program in real time. you can even log all the output to a file. It is useful when you access the server via ssh where you get logged out due to poor connection or inactivity. After logging in you can continue the work from where you left. refer this and this to know in detail.
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
add a comment |
Instead of using nohup you can use screen. You can view the status of the program in real time. you can even log all the output to a file. It is useful when you access the server via ssh where you get logged out due to poor connection or inactivity. After logging in you can continue the work from where you left. refer this and this to know in detail.
Instead of using nohup you can use screen. You can view the status of the program in real time. you can even log all the output to a file. It is useful when you access the server via ssh where you get logged out due to poor connection or inactivity. After logging in you can continue the work from where you left. refer this and this to know in detail.
answered Jan 27 '17 at 6:15
ManiMani
1212
1212
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
add a comment |
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
This is awesome, thank you :)
– Botond
Jan 19 at 1:22
add a comment |
The tee
command is pretty prevalent too.
nohup java -jar myProgram.jar | tee output.log &
add a comment |
The tee
command is pretty prevalent too.
nohup java -jar myProgram.jar | tee output.log &
add a comment |
The tee
command is pretty prevalent too.
nohup java -jar myProgram.jar | tee output.log &
The tee
command is pretty prevalent too.
nohup java -jar myProgram.jar | tee output.log &
answered 3 hours ago
trevorgraysontrevorgrayson
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f74520%2fcan-i-redirect-output-to-a-log-file-and-background-a-process-at-the-same-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have you tried it? What error do you get? Also I'm not sure if you have a typo, or an error in your code.
2>$1
is probably supposed to be2>&1
.– Patrick
May 3 '13 at 0:10