Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to be able to run task(s) in the background of a shell and not have their output to stdout or stderr cover the command line at the bottom. Frequently I need to run other commands to interact with the background processes and would like to do so from the same shell without having to open up another terminal or using multiplexer to split the terminal like screen.

Ideally there would be some setting that I just don't know about (I commonly use bash or ksh), but a new or different shell or a script would be fine by me.

I'm open to any suggestions and appreciate any help, thanks.

Edit: Thank you for all of your answers, but my question was a bit unclear. I still need to watch the output of the backgrounded tasks as it comes out, I would just like it to not cover any new commands I might be typing on the command line. Ideally, the output from backgrounded programs would be displayed in all but the bottom line of the shell leaving me free to construct new commands in that line.

This would be similar to running screen with a horizontal split where the bottom window was only 1-2 lines tall, but using screen has the following drawbacks for my purposes:

  • I don't need/want the processes to survive past my logout
  • It takes an extra command or two to set up (even if the split and window sizing are done on a .screenrc file)
  • I'd like to be able to use the shell's job control commands without switching between screen windows (ie jobs, bg, fg, kill %1 at least in the case of bash)

Thanks again for your help, this was my first question and I've been blown away by the speed and quantity of the answers!

share|improve this question
    
What is wrong with screen? –  Justin Mar 21 '10 at 0:58
    
@Justin: it's more work than just pressing Cltr+Z, bg, and you have to decide to use screen before running the command. –  porneL May 17 '10 at 13:10
add comment

4 Answers

In Bash & ksh, you can make all stdout disappear by appending 1>/dev/null to the command.
For csh and tcsh it's $1>/dev/null

share|improve this answer
add comment
mycommand > /dev/null 2>&1

This will redirect stderror (2) to stdout (1) to /dev/null

share|improve this answer
    
Yep, technically, it redirects strerr to stdout (2>&1), and stdout to /dev/null (>/dev/null). –  Chris S Mar 22 '10 at 0:48
add comment

From the 'nohup' wikipedia page to expand on the answers already given....

nohup ./myprogram > foo.out 2> foo.err < /dev/null &

http://en.wikipedia.org/wiki/Nohup

nohup allows the process to continue after you terminate the shell should you need to do that. The '>' and '<' redirect the output to a 'file' whatever that file should be. In some of the examples given that file is just /dev/null. The '&' tells the shell to put the process in the background and continue to accept input as the OP likely already knows.

share|improve this answer
add comment

Depending on how tight your system administrator has on his security you could run the command using 'at'.

 $ at now
 date 
 id
 ^D
 $ 

Of course the output (if any) would be emailed to you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.