4

I've written a tcsh script to clear garbage data in a cluster, the code is :

set hosts = $1
set clear_path = $2
foreach i ($hosts)
    rsh $i rm -rvf $clear_path
end

When I run this script in the background like this :

disk_clean.sh hosts_all /u0/data/tmp > log &

The job will get stuck and show the information like this:

[1] + Suspended (tty input)

If I run this in foreground, it can finish normally. Why does this happen? How can I run this script in the background and redirect the output into a log file?

WindKnight
  • 53
  • 1
  • 4
  • 2
    Rsh reads from standard input (the terminal in your case) and passes the data to the remote system. Unix and Linux systems stop a process when it's in the background and tries to read from the terminal. Give rsh the `-n` option to tell it not to read anything from standard input. – Mark Plotnick Feb 21 '17 at 07:49
  • https://www.gnu.org/software/libc/manual/html_node/Access-to-the-Terminal.html#Access-to-the-Terminal – melpomene Feb 21 '17 at 08:18
  • It works, thanks a lot! It seems that I didn't read the manpage of rsh carefully. – WindKnight Feb 21 '17 at 08:40

0 Answers0