One-liner to execute a process in a current directory with no output and disown it?
I'm trying to do something fairly simple:
$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'
How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?
bash disown
add a comment |
I'm trying to do something fairly simple:
$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'
How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?
bash disown
add a comment |
I'm trying to do something fairly simple:
$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'
How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?
bash disown
I'm trying to do something fairly simple:
$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'
How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?
bash disown
bash disown
edited Jan 21 '16 at 19:01
lesmana
14.5k115873
14.5k115873
asked Jan 24 '13 at 1:32
Naftuli KayNaftuli Kay
12.5k56159256
12.5k56159256
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The problem is that you are using both &
and ;
together. They are both command terminators, and can not be used at the same time. Here is your example fixed:
( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
add a comment |
The nohup utility was designed for pretty much what you're looking for:
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.
If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
add a comment |
This worked for me:
$(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &
New contributor
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%2f62346%2fone-liner-to-execute-a-process-in-a-current-directory-with-no-output-and-disown%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that you are using both &
and ;
together. They are both command terminators, and can not be used at the same time. Here is your example fixed:
( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
add a comment |
The problem is that you are using both &
and ;
together. They are both command terminators, and can not be used at the same time. Here is your example fixed:
( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
add a comment |
The problem is that you are using both &
and ;
together. They are both command terminators, and can not be used at the same time. Here is your example fixed:
( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
The problem is that you are using both &
and ;
together. They are both command terminators, and can not be used at the same time. Here is your example fixed:
( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )
answered Jan 24 '13 at 1:54
jordanmjordanm
30.9k38695
30.9k38695
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
add a comment |
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks
– akskap
Apr 30 '18 at 13:24
add a comment |
The nohup utility was designed for pretty much what you're looking for:
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.
If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
add a comment |
The nohup utility was designed for pretty much what you're looking for:
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.
If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
add a comment |
The nohup utility was designed for pretty much what you're looking for:
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.
If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
The nohup utility was designed for pretty much what you're looking for:
Usage: nohup COMMAND [ARG]...
or: nohup OPTION
Run COMMAND, ignoring hangup signals.
If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.
answered Jan 24 '13 at 5:54
tylerltylerl
1,866816
1,866816
add a comment |
add a comment |
This worked for me:
$(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &
New contributor
add a comment |
This worked for me:
$(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &
New contributor
add a comment |
This worked for me:
$(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &
New contributor
This worked for me:
$(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &
New contributor
New contributor
answered 12 mins ago
UlysnepUlysnep
1
1
New contributor
New contributor
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%2f62346%2fone-liner-to-execute-a-process-in-a-current-directory-with-no-output-and-disown%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