LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 11-25-2011, 04:08 AM   #1
rohit_6080
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Redirecting Error Output


Hi can someone please guide me on how to redirect the standard error of a script into a file?
 
Old 11-25-2011, 04:26 AM   #2
bluesatbridge
Member
 
Registered: Oct 2010
Location: england
Distribution: debian , redhat
Posts: 36

Rep: Reputation: 2
script-name 2> error.log

cheers
 
1 members found this post helpful.
Old 11-25-2011, 05:31 AM   #3
wsteward
LQ Newbie
 
Registered: Feb 2007
Posts: 8

Rep: Reputation: 2
This is an example of a cron job that redirects standard output and standard error of a script to a file called archive_backup.

#Archive Backup Log
01 7 1 * * /bin/bash -v /mnt/nfs-f13-live/my_scripts/archive_backup_log >>/home/bill/archive_backup.log 2>&1
 
Old 11-25-2011, 06:01 AM   #4
rohit_6080
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
thanxx guys it worked...i appreciate your help......
 
Old 11-25-2011, 06:10 AM   #5
rohit_6080
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
one more question :

how can i set error redirection within the script. i do not want to write scriptname.sh 2>error.log ,i just want to run the script normally like ./scriptname & want errors to be redirected in a file.Thanxx beforehand.
 
Old 11-25-2011, 08:21 AM   #6
wsteward
LQ Newbie
 
Registered: Feb 2007
Posts: 8

Rep: Reputation: 2
For the errors to be trapped within the script you must write the redirects in the script and designate the error file. That way when you run your ./scriptname the errors generated within the script will be piped to the error file.
 
Old 11-25-2011, 09:48 AM   #7
rohit_6080
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
i've been trying to do that but i m getting syntax error each time.
 
Old 11-25-2011, 02:44 PM   #8
wsteward
LQ Newbie
 
Registered: Feb 2007
Posts: 8

Rep: Reputation: 2
What is the syntax error and command you are running?
 
  


Reply



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
A little help with redirecting output tybalt Linux - Newbie 1 08-04-2007 10:08 PM
redirecting output using > cmk77 Slackware 8 11-10-2006 02:08 AM
Redirecting sh output to a pipe elmafiacs Programming 0 05-10-2006 01:55 PM
Redirecting output from XEV 3saul Linux - Software 1 02-26-2006 01:14 PM
redirecting xmms output durden2.0 Linux - Software 0 03-06-2004 07:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:30 AM.

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
Open Source Consulting | Domain Registration