LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Output to log file (https://www.linuxquestions.org/questions/linux-newbie-8/output-to-log-file-860288/)

BfJj 02-02-2011 02:40 PM

Output to log file
 
Being a newbe over 50, I need to be able to send the output of a *.sh script to a Log file when it completes. What is the syntext?
Thanks, Bill

acid_kewpie 02-02-2011 02:43 PM

there is no real syntax for this at all, other than just doing a redirect, i.e. "myscript.sh > logfile.txt". That would redirect all the standard output, but you'd probably also want the standard error, in which case expand it slightly to "myscript.sh 2>&1 > logfile.txt".

You might like to have a slicker method though and use the logger command within your script to send log messages directly into syslog, which you could then pull out via your syslog config into it's own file, or just let it hit /var/log/messages by default.


All times are GMT -5. The time now is 09:21 PM.