Bash script to log the output of the script to a separate log fileredirect and log script outputShell Script...

If protons are the only stable baryons, why do they decay into neutrons in positron emission?

Why isn’t the tax system continuous rather than bracketed?

Analog is Obtuse!

Do 3D printers really reach 50 micron (0.050mm) accuracy?

Do I have to roll to maintain concentration if a target other than me who is affected by my concentration spell takes damage?

How should I behave to assure my friends that I am not after their money?

MH370 blackbox - is it still possible to retrieve data from it?

Intuitively, why does putting capacitors in series decrease the equivalent capacitance?

Wilcoxon signed rank test – critical value for n>50

Reverse of diffraction

Three column layout

Disabling automatic add after resolving git conflict

How to convert object fill in to fine lines?

Why would less-bright meteors be more valuable to spot?

Should I hide continue button until tasks are completed?

In native German words, is Q always followed by U, as in English?

Was touching your nose a greeting in second millenium Mesopotamia?

How do I find and plot the intersection of these three surfaces?

The difference between Rad1 and Rfd1

Why is Bézout's identity considered an identity?

Why is the Turkish president's surname spelt in Russian as Эрдоган, with г?

Can a US President have someone sent to prison?

How do I spend money in Sweden and Denmark?

Bash echo $-1 prints hb1. Why?



Bash script to log the output of the script to a separate log file


redirect and log script outputShell Script Output not written to file properlyAccumulate Filename in a Log file using shell scriptWhat is wrong with my init.d script [Segmentation fault]How to log from inside the script along with stdoutgrep script - output lines at the same time into echoPipe to log file with today's date contained in filenameCreate a multi-script bash script that is compiled and keeps a logGet the log for last 10 minutes from nginx access logCron log file isn't updating






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have written a scipt(example.sh) to echo the date and system uptime on stdout. At the same time I want this script to log this output into a log file.
Here's my code



echo `date`
echo `uptime`


And at last



cat /home/rpeb/example.sh 1> /home/rpeb/example.log 


to redirect the output into a log file.



I don't want the last line to be logged. What changes should I make to this code?










share|improve this question







New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What do you mean by I don't want the last line to be logged ? which last line?

    – matsib.dev
    6 mins ago


















0















I have written a scipt(example.sh) to echo the date and system uptime on stdout. At the same time I want this script to log this output into a log file.
Here's my code



echo `date`
echo `uptime`


And at last



cat /home/rpeb/example.sh 1> /home/rpeb/example.log 


to redirect the output into a log file.



I don't want the last line to be logged. What changes should I make to this code?










share|improve this question







New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • What do you mean by I don't want the last line to be logged ? which last line?

    – matsib.dev
    6 mins ago














0












0








0








I have written a scipt(example.sh) to echo the date and system uptime on stdout. At the same time I want this script to log this output into a log file.
Here's my code



echo `date`
echo `uptime`


And at last



cat /home/rpeb/example.sh 1> /home/rpeb/example.log 


to redirect the output into a log file.



I don't want the last line to be logged. What changes should I make to this code?










share|improve this question







New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have written a scipt(example.sh) to echo the date and system uptime on stdout. At the same time I want this script to log this output into a log file.
Here's my code



echo `date`
echo `uptime`


And at last



cat /home/rpeb/example.sh 1> /home/rpeb/example.log 


to redirect the output into a log file.



I don't want the last line to be logged. What changes should I make to this code?







shell-script






share|improve this question







New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 43 mins ago









Prakash DubeyPrakash Dubey

11 bronze badge




11 bronze badge




New contributor



Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Prakash Dubey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • What do you mean by I don't want the last line to be logged ? which last line?

    – matsib.dev
    6 mins ago



















  • What do you mean by I don't want the last line to be logged ? which last line?

    – matsib.dev
    6 mins ago

















What do you mean by I don't want the last line to be logged ? which last line?

– matsib.dev
6 mins ago





What do you mean by I don't want the last line to be logged ? which last line?

– matsib.dev
6 mins ago










0






active

oldest

votes














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


}
});






Prakash Dubey is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f526541%2fbash-script-to-log-the-output-of-the-script-to-a-separate-log-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Prakash Dubey is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Prakash Dubey is a new contributor. Be nice, and check out our Code of Conduct.













Prakash Dubey is a new contributor. Be nice, and check out our Code of Conduct.












Prakash Dubey is a new contributor. Be nice, and check out our Code of Conduct.
















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%2f526541%2fbash-script-to-log-the-output-of-the-script-to-a-separate-log-file%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







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m