LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-02-2011, 03:40 PM   #1
BfJj
LQ Newbie
 
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
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
 
Old 02-02-2011, 03:43 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Clean Up Log - Search for Pattern in Log file and Output result bridrod Linux - Newbie 10 01-05-2010 10:49 AM
How do i log GNU screen output to a file ? RadishTP Linux - Newbie 3 06-12-2009 03:35 PM
tty2 boot output - log file? neilneil2000 Linux - Newbie 9 06-10-2008 11:54 AM
How to direct output both log file and to terminal... freebies Linux - General 1 02-25-2005 07:32 AM
Log Screen Output to a file sdandeker Linux - Newbie 3 09-17-2003 03:57 AM


All times are GMT -5. The time now is 02:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration