Linux csh script going to Suspended (tty output) when running with & (bg)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux csh script going to Suspended (tty output) when running with & (bg)
# 1  
Old 08-07-2014
Linux csh script going to Suspended (tty output) when running with & (bg)

i have strange behavior i have csh file that run java process something like this :

run_server.csh

Code:
    #!/usr/bin/tcsh
    
    java -Dtest=testparam -cp ${TEST}/lib/device.jar:${TEST}/conf:${TEST}/lib/commons-logging-1.1.1.jar  com.device.server

when i run it like this :
Code:
run_server.csh&

in the putty shell in linux
im getting this massage :

Code:
    [2]  + Suspended (tty output)        run_server.csh

Although when i run it without the ampersand the server is running and outputting its log massages into the stdout but the problem is when i press ctr+c the process is killed

another strange thing is if i write wrapper script to run_server.csh
that looked like this run_server_wrapper.csh:


Code:
    #!/usr/bin/tcsh 
    run_server.csh &
    sleep 5

it does run the server as bg process and the run_server_wrapper.csh it self
getting the massage :

Code:
    [2]  + Suspended (tty output)        run_server_wrapper.csh

what is the problem here ?

Last edited by Corona688; 08-07-2014 at 12:45 PM..
# 2  
Old 08-07-2014
If a background process tries to read from the terminal, it will be stopped. This is normal terminal and shell behavior. Only foreground processes are allowed to control the terminal like that.

To prevent it from reading from the terminal, run it with nohup to prevent it from accessing the terminal. This will redirect stdin/stdout/stderr automatically. stdin will connect to /dev/null, while stdout and stderr will be saved to a file in the current directory.

Code:
nohup run_server.csh

# 3  
Old 08-07-2014
As Corona688 said, you better use nohup, but I think he missed the & at the end.

Code:
nohup run_server.csh &

# 4  
Old 08-07-2014
Thanks for the replays even if i added the nohup and the "&" at the end i still have the same problem
# 5  
Old 08-07-2014
Then your java program must be opening /dev/tty directly, that would also freeze it.

Are you on Linux? You could do
Code:
setsid nohup ...

to put it in a new session group, independent of the current terminal.
# 6  
Old 08-07-2014
ok asked the developers to remove all prints to stdout
Thanks!
# 7  
Old 08-07-2014
No, don't do that!

Reading from the controlling terminal gets it frozen. Writing is usually okay.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

>& >&! in /bin/csh

i am new player in linux what does mean ">& and >&!" in script or command line? thanks (4 Replies)
Discussion started by: abdossamad2003
4 Replies

2. Shell Programming and Scripting

Different output for awk command on Linux & HP-UX

I am using an awk command to extract a particular portion of a string. Below is the command and its output on a Linux system: oracle@host1:/tmp (/home/oracle) $uname -a Linux host1 2.6.32-279.39.1.el6.x86_64 #1 SMP Fri Nov 15 05:38:26 EST 2013 x86_64 x86_64 x86_64 GNU/Linux ... (7 Replies)
Discussion started by: veeresh_15
7 Replies

3. Shell Programming and Scripting

>& redirection not working within csh script

I'm having a strange problem with basic >& output redirection to a simple log file in csh. When I run this particular output redirection on the command line, it works, but then when I run the same output redirection command >& in my c shell script, I get a blank log file. Nothing is output to the... (5 Replies)
Discussion started by: silencio
5 Replies

4. Shell Programming and Scripting

Linux Platform - NDM Script - && Operator

Hi All, I have a requirement where i need to NDM 3 files from LINUX to Mainframe system & trigger a job in mainframe once the 3 files are transmitted successfully. I am getting an error message in the && operator (the code component where i am checking whether step 1/2/3 are completed). ... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. UNIX for Dummies Questions & Answers

What are these different tty processes(tty1,tty2..) running as root mentioned n the list below.

Hi, I need your help to understand about different processes(tty1,tty2,tty3...) running as root as shown below .What exactly these processes do? root@bisu-desktop:~# ps -eaf | grep -e tty -e UID UID PID PPID C STIME TTY TIME CMD root 761 1 0 10:30 tty5 ... (4 Replies)
Discussion started by: crazybisu
4 Replies

6. Shell Programming and Scripting

Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni. Below is the code but it is giving error. :confused: #!/bin/csh FILES_NAME ='files_list'; FILE_NAME_PATTERN = 'uni*'; NO_OF_FILES; ls -l $FILE_NAME_PATTERN > $FILES_NAME ; NO_OF_FILES = `wc -l $FILES_NAME`; echo... (3 Replies)
Discussion started by: hiten.r.chauhan
3 Replies

7. Shell Programming and Scripting

What does this really mean? "tty -s && stty istrip"

I am having hard time understanding what this really do to the environment? I do understand this part "tty -s && stty " but not "istrip" # stty command is executed only if a tty is attached to the process. # stty istrip : Strip input characters to 7 bits tty -s && stty istrip I am... (3 Replies)
Discussion started by: kchinnam
3 Replies

8. Shell Programming and Scripting

simple CSH Script behaves differently on Solaris and RedHat Linux

I have a simple csh-script on a Solaris Workstaion which invokes the bc calculator: #!/bin/csh set shz=2 set zshift=5 set shzp=`bc -l <<END \ scale = 3 \ -1. * $shz + $zshift \ END` echo $shzp The result ($shzp) in this case is 3 (-1*2+5). It works fine on Solaris 8. ... (2 Replies)
Discussion started by: two reelers
2 Replies

9. Shell Programming and Scripting

TTY colors are screwing up my output

I have been trying to get the output of an ssh session pushed to file... the problem is that there are colors in the output, and when I view the file the colors show up as "^[00m" or other such various nonsense The weird part is that if I do this all manually, I have no problems, but if I try to... (0 Replies)
Discussion started by: jjinno
0 Replies

10. Shell Programming and Scripting

Stopped (tty output)

What is mean by "Stopped (tty output)", how can i get rid of it. (3 Replies)
Discussion started by: Chandu
3 Replies
Login or Register to Ask a Question