Use "nohup" to run "top" command in background

Richard picture Richard · Oct 2, 2012 · Viewed 8.9k times · Source

I have problems in using nohup to run top command in the background. First, I run it locally, as

nohup top &

it complains in nohup.out with text top: failed to get tty. My ultimate goal is to run top on remote machine, like

nohup ssh -t user@hostname top &

currently, the above command also fails with

Pseudo-terminal will not be allocated because stdin is not a terminal.^M 
TERM environment variable not set

Any ideas?

PS: I run this command to ping machineB from machineA. machineA is always alive, but not not always logged in.

Answer

ggiroux picture ggiroux · Oct 2, 2012

Have you tried the -b (batch mode) switch of the top command?