Running a process in the background
I have 2 questions about starting the processes in the background:
Why does starting a process in the background like so:
./my_program &
(
my_program
have exe permission set of course) doesn't make the
bash to print the command prompt like any other commands? It just
left a empty new line with blinking cursor.
When i run a next new processes in the background bash displays sth.
like that:
./my_program &
[30] 1439
[27] Done ./my_program
[28] Done ./my_program
[29] Done ./my_program
does this mean that starting
another extra processes in the background makes the system to
display an info about the previews processes ([27], [28], [29]
lines) as long as the currently started) ([30]
line)?
linux bash
add a comment |
I have 2 questions about starting the processes in the background:
Why does starting a process in the background like so:
./my_program &
(
my_program
have exe permission set of course) doesn't make the
bash to print the command prompt like any other commands? It just
left a empty new line with blinking cursor.
When i run a next new processes in the background bash displays sth.
like that:
./my_program &
[30] 1439
[27] Done ./my_program
[28] Done ./my_program
[29] Done ./my_program
does this mean that starting
another extra processes in the background makes the system to
display an info about the previews processes ([27], [28], [29]
lines) as long as the currently started) ([30]
line)?
linux bash
What happens if you just press<return>
again? do you get a prompt?
– Attie
Dec 10 at 16:22
add a comment |
I have 2 questions about starting the processes in the background:
Why does starting a process in the background like so:
./my_program &
(
my_program
have exe permission set of course) doesn't make the
bash to print the command prompt like any other commands? It just
left a empty new line with blinking cursor.
When i run a next new processes in the background bash displays sth.
like that:
./my_program &
[30] 1439
[27] Done ./my_program
[28] Done ./my_program
[29] Done ./my_program
does this mean that starting
another extra processes in the background makes the system to
display an info about the previews processes ([27], [28], [29]
lines) as long as the currently started) ([30]
line)?
linux bash
I have 2 questions about starting the processes in the background:
Why does starting a process in the background like so:
./my_program &
(
my_program
have exe permission set of course) doesn't make the
bash to print the command prompt like any other commands? It just
left a empty new line with blinking cursor.
When i run a next new processes in the background bash displays sth.
like that:
./my_program &
[30] 1439
[27] Done ./my_program
[28] Done ./my_program
[29] Done ./my_program
does this mean that starting
another extra processes in the background makes the system to
display an info about the previews processes ([27], [28], [29]
lines) as long as the currently started) ([30]
line)?
linux bash
linux bash
asked Dec 10 at 16:21
Mulligun007
122
122
What happens if you just press<return>
again? do you get a prompt?
– Attie
Dec 10 at 16:22
add a comment |
What happens if you just press<return>
again? do you get a prompt?
– Attie
Dec 10 at 16:22
What happens if you just press
<return>
again? do you get a prompt?– Attie
Dec 10 at 16:22
What happens if you just press
<return>
again? do you get a prompt?– Attie
Dec 10 at 16:22
add a comment |
1 Answer
1
active
oldest
votes
This shouldn't happen. When you run a command in the background bash usually just prints the job number and pid (see below) and then drops back to a command prompt.
The only reason I know of that leads bash to leave you with a new line in this situation is if your command doesn't actually exist, as it will somehow give the error message for that after printing PS1:
$ nonexistant_command &
[1] 13856
$
nonexistant_command: command not found
<empty line with blinking cursor here>
Whatever the cause may be, pressing enter while on this empty line should print a new line with your usual prompt (and, possibly, the message that the job you just spawned finished; see below).
The additional output you see is bash telling you about current background jobs:
First, it tells you the current job number of any newly created background process together with its pid, like so:
$ some_command
[1] 1234
This means that the command
some_command
is now being run with the pid 1234 as job 1.
Once a background job finishes, bash will notify you of this the next time it prints a command prompt (whether it be because you spawned another background process, ran a command in the foreground or simply pressed enter with an empty command line) by printing a message like this:
[1] Done some_command
This means that the job with the number 1 which ran
some_command
has now finished.
To find out what background jobs bash is currently tracking, you can use the
jobs
builtin like so:
$ jobs
[1] Running some_command &
[2] Running some_other_command &
To bring a job to the foreground, you can use
fg
:
$ fg 2
some_other_command
For more info on this, try
help jobs
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1382366%2frunning-a-process-in-the-background%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This shouldn't happen. When you run a command in the background bash usually just prints the job number and pid (see below) and then drops back to a command prompt.
The only reason I know of that leads bash to leave you with a new line in this situation is if your command doesn't actually exist, as it will somehow give the error message for that after printing PS1:
$ nonexistant_command &
[1] 13856
$
nonexistant_command: command not found
<empty line with blinking cursor here>
Whatever the cause may be, pressing enter while on this empty line should print a new line with your usual prompt (and, possibly, the message that the job you just spawned finished; see below).
The additional output you see is bash telling you about current background jobs:
First, it tells you the current job number of any newly created background process together with its pid, like so:
$ some_command
[1] 1234
This means that the command
some_command
is now being run with the pid 1234 as job 1.
Once a background job finishes, bash will notify you of this the next time it prints a command prompt (whether it be because you spawned another background process, ran a command in the foreground or simply pressed enter with an empty command line) by printing a message like this:
[1] Done some_command
This means that the job with the number 1 which ran
some_command
has now finished.
To find out what background jobs bash is currently tracking, you can use the
jobs
builtin like so:
$ jobs
[1] Running some_command &
[2] Running some_other_command &
To bring a job to the foreground, you can use
fg
:
$ fg 2
some_other_command
For more info on this, try
help jobs
add a comment |
This shouldn't happen. When you run a command in the background bash usually just prints the job number and pid (see below) and then drops back to a command prompt.
The only reason I know of that leads bash to leave you with a new line in this situation is if your command doesn't actually exist, as it will somehow give the error message for that after printing PS1:
$ nonexistant_command &
[1] 13856
$
nonexistant_command: command not found
<empty line with blinking cursor here>
Whatever the cause may be, pressing enter while on this empty line should print a new line with your usual prompt (and, possibly, the message that the job you just spawned finished; see below).
The additional output you see is bash telling you about current background jobs:
First, it tells you the current job number of any newly created background process together with its pid, like so:
$ some_command
[1] 1234
This means that the command
some_command
is now being run with the pid 1234 as job 1.
Once a background job finishes, bash will notify you of this the next time it prints a command prompt (whether it be because you spawned another background process, ran a command in the foreground or simply pressed enter with an empty command line) by printing a message like this:
[1] Done some_command
This means that the job with the number 1 which ran
some_command
has now finished.
To find out what background jobs bash is currently tracking, you can use the
jobs
builtin like so:
$ jobs
[1] Running some_command &
[2] Running some_other_command &
To bring a job to the foreground, you can use
fg
:
$ fg 2
some_other_command
For more info on this, try
help jobs
add a comment |
This shouldn't happen. When you run a command in the background bash usually just prints the job number and pid (see below) and then drops back to a command prompt.
The only reason I know of that leads bash to leave you with a new line in this situation is if your command doesn't actually exist, as it will somehow give the error message for that after printing PS1:
$ nonexistant_command &
[1] 13856
$
nonexistant_command: command not found
<empty line with blinking cursor here>
Whatever the cause may be, pressing enter while on this empty line should print a new line with your usual prompt (and, possibly, the message that the job you just spawned finished; see below).
The additional output you see is bash telling you about current background jobs:
First, it tells you the current job number of any newly created background process together with its pid, like so:
$ some_command
[1] 1234
This means that the command
some_command
is now being run with the pid 1234 as job 1.
Once a background job finishes, bash will notify you of this the next time it prints a command prompt (whether it be because you spawned another background process, ran a command in the foreground or simply pressed enter with an empty command line) by printing a message like this:
[1] Done some_command
This means that the job with the number 1 which ran
some_command
has now finished.
To find out what background jobs bash is currently tracking, you can use the
jobs
builtin like so:
$ jobs
[1] Running some_command &
[2] Running some_other_command &
To bring a job to the foreground, you can use
fg
:
$ fg 2
some_other_command
For more info on this, try
help jobs
This shouldn't happen. When you run a command in the background bash usually just prints the job number and pid (see below) and then drops back to a command prompt.
The only reason I know of that leads bash to leave you with a new line in this situation is if your command doesn't actually exist, as it will somehow give the error message for that after printing PS1:
$ nonexistant_command &
[1] 13856
$
nonexistant_command: command not found
<empty line with blinking cursor here>
Whatever the cause may be, pressing enter while on this empty line should print a new line with your usual prompt (and, possibly, the message that the job you just spawned finished; see below).
The additional output you see is bash telling you about current background jobs:
First, it tells you the current job number of any newly created background process together with its pid, like so:
$ some_command
[1] 1234
This means that the command
some_command
is now being run with the pid 1234 as job 1.
Once a background job finishes, bash will notify you of this the next time it prints a command prompt (whether it be because you spawned another background process, ran a command in the foreground or simply pressed enter with an empty command line) by printing a message like this:
[1] Done some_command
This means that the job with the number 1 which ran
some_command
has now finished.
To find out what background jobs bash is currently tracking, you can use the
jobs
builtin like so:
$ jobs
[1] Running some_command &
[2] Running some_other_command &
To bring a job to the foreground, you can use
fg
:
$ fg 2
some_other_command
For more info on this, try
help jobs
answered Dec 20 at 12:41
Entropy0
112
112
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f1382366%2frunning-a-process-in-the-background%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
What happens if you just press
<return>
again? do you get a prompt?– Attie
Dec 10 at 16:22