Questions using - someprog > /dev/null 2>&1

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I know in linux you would use that with a command to make any output by that command to be silent but I was just wondeing if anybody could explain the last part of this

someprog > /dev/null 2>&1

It makes sense to me to use the > /dev/null so that the output goes to null and disappears, but what exactly does the 2>&1 do ? Thanks if anybody knows the answer.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • vili
  • Born
  • Born
  • User avatar
  • Posts: 3

Post 3+ Months Ago

The first part, "> /dev/null" means send standard output to the 'bit
bucket" or in other words, throw it away.

The second part, "2>&1" means "redirect standard error (2) to the same
place as standard outout (1.)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Thanks for the reply, I was wondering if anybody was ever going to help me out there :)

Also I think you mean standard output, not standard outout :wink:
  • vili
  • Born
  • Born
  • User avatar
  • Posts: 3

Post 3+ Months Ago

You are correct
  • torkil
  • Born
  • Born
  • torkil
  • Posts: 1

Post 3+ Months Ago

I have a shell script that is running daily - at midnight - on my linux box, and lately it has been returning some strange error messages. At the same time, my disk stats show that my system partition on my harddrive is being loaded with lots of data at midnight every day, and my system stats show that cpu utilization is close to 100% from midnight and for several hours after that.

I am assuming that this process is making life hard on my server... My question is: The data that this process generates - where is it stored? I mean... if it just spits out lots of errors, there has to be a huge error log here somewhere?

(if you hadn't guessed already, I'm a bit of a novice when it comes to linux....)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Did you check the mail under the root account? or the owner's mail of the acount starting the process?
  • compdude
  • Born
  • Born
  • compdude
  • Posts: 4

Post 3+ Months Ago

Why would I not forward stout to ">> /var/adm/messages 2>$1"

This way I still get tracking info and it is automatically flushed via cron.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 33 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.