Can I redirect output to a log file and background a process at the same time?2019 Community Moderator ElectionUnable to write to file in shell script when running command in backgroundredirect and log script outputhow to properly log the output of a console program that frequently updates “parts” of the screen, resulting in a messy log file?How can I redirect the output of a child process?grep script - output lines at the same time into echoHow to run process in background and get its pid to create log file nameHow to redirect output to a log from expect commandHow to clear a redirect log file content in shell?Log background jobs started in all the manually started shells?Why do `jobs` and `dirs` run in command subsitution, process substitution, pipeline, and background jobs output the same as in original shell?How to redirect output to file to STDOUT?

Makefile strange variable substitution

Are all players supposed to be able to see each others' character sheets?

How to draw cubes in a 3 dimensional plane

Shifting between bemols (flats) and diesis (sharps)in the key signature

They call me Inspector Morse

An alternative proof of an application of Hahn-Banach

Virginia employer terminated employee and wants signing bonus returned

Why was Goose renamed from Chewie for the Captain Marvel film?

Accepted offer letter, position changed

Why does Captain Marvel assume the people on this planet know this?

Word for a person who has no opinion about whether god exists

Are babies of evil humanoid species inherently evil?

How do I express some one as a black person?

Am I not good enough for you?

Does the nature of the Apocalypse in The Umbrella Academy change from the first to the last episode?

Definition of Statistic

What problems would a superhuman have whose skin is constantly hot?

meaning and function of 幸 in "则幸分我一杯羹"

Can one live in the U.S. and not use a credit card?

How to write ı (i without dot) character in pgf-pie

Filtering SOQL results with optional conditionals

Declaring and defining template, and specialising them

How can I ensure my trip to the UK will not have to be cancelled because of Brexit?

Vocabulary for giving just numbers, not a full answer



Can I redirect output to a log file and background a process at the same time?



2019 Community Moderator ElectionUnable to write to file in shell script when running command in backgroundredirect and log script outputhow to properly log the output of a console program that frequently updates “parts” of the screen, resulting in a messy log file?How can I redirect the output of a child process?grep script - output lines at the same time into echoHow to run process in background and get its pid to create log file nameHow to redirect output to a log from expect commandHow to clear a redirect log file content in shell?Log background jobs started in all the manually started shells?Why do `jobs` and `dirs` run in command subsitution, process substitution, pipeline, and background jobs output the same as in original shell?How to redirect output to file to STDOUT?










97















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









share|improve this question



















  • 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
















97















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









share|improve this question



















  • 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














97












97








97


45






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









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 be 2>&1.

    – Patrick
    May 3 '13 at 0:10













  • 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








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











5 Answers
5






active

oldest

votes


















146














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.






share|improve this answer

























  • 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 putting 2>&1 in the wrong place in your command line.

    – Dan
    Jan 4 '17 at 21:33


















13














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






share|improve this answer

























  • 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 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



















6














java -jar myProgram.jar &> output.log &


Note that the &> directs both stdout and stderr to output.log






share|improve this answer




















  • 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


















1














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.






share|improve this answer























  • This is awesome, thank you :)

    – Botond
    Jan 19 at 1:22


















0














The tee command is pretty prevalent too.



nohup java -jar myProgram.jar | tee output.log &






share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    146














    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.






    share|improve this answer

























    • 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 putting 2>&1 in the wrong place in your command line.

      – Dan
      Jan 4 '17 at 21:33















    146














    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.






    share|improve this answer

























    • 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 putting 2>&1 in the wrong place in your command line.

      – Dan
      Jan 4 '17 at 21:33













    146












    146








    146







    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.






    share|improve this answer















    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 putting 2>&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






    • 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
















    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













    13














    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






    share|improve this answer

























    • 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 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
















    13














    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






    share|improve this answer

























    • 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 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














    13












    13








    13







    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






    share|improve this answer















    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







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 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


















    • 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 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

















    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












    6














    java -jar myProgram.jar &> output.log &


    Note that the &> directs both stdout and stderr to output.log






    share|improve this answer




















    • 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















    6














    java -jar myProgram.jar &> output.log &


    Note that the &> directs both stdout and stderr to output.log






    share|improve this answer




















    • 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













    6












    6








    6







    java -jar myProgram.jar &> output.log &


    Note that the &> directs both stdout and stderr to output.log






    share|improve this answer















    java -jar myProgram.jar &> output.log &


    Note that the &> directs both stdout and stderr to output.log







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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












    • 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











    1














    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.






    share|improve this answer























    • This is awesome, thank you :)

      – Botond
      Jan 19 at 1:22















    1














    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.






    share|improve this answer























    • This is awesome, thank you :)

      – Botond
      Jan 19 at 1:22













    1












    1








    1







    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.






    share|improve this answer













    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 27 '17 at 6:15









    ManiMani

    1212




    1212












    • 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





    This is awesome, thank you :)

    – Botond
    Jan 19 at 1:22











    0














    The tee command is pretty prevalent too.



    nohup java -jar myProgram.jar | tee output.log &






    share|improve this answer



























      0














      The tee command is pretty prevalent too.



      nohup java -jar myProgram.jar | tee output.log &






      share|improve this answer

























        0












        0








        0







        The tee command is pretty prevalent too.



        nohup java -jar myProgram.jar | tee output.log &






        share|improve this answer













        The tee command is pretty prevalent too.



        nohup java -jar myProgram.jar | tee output.log &







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 3 hours ago









        trevorgraysontrevorgrayson

        1012




        1012



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            -bash, shell, shell-script

            Popular posts from this blog

            Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

            Frič See also Navigation menuinternal link

            Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant