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.

In my Linux machine I have binary script (called transferNames.bin )

The problem is that when I run transferNames.bin with & script stuck and not returns to Linux prompt “#”, even if I wait 1 day or more ( so I cant continue work on my Linux because its stuck ) Example:

  [root@linux1 tmp]# ./transferNames.bin &  
                     Transferring..

also diff way:

  [root@linux1 tmp]# ( /tmp/transferNames.bin ) &  
                     Transferring..

remark - transferNames.bin script work fine and I can’t edit this script

My question please advice if I can to run the ./transferNames.bin &
on other shell - how to do that?

In order to avoid the stuck problem? Or any other solution in order to run ./transferNames.bin & but on other shell? or any other opinion ?

share|improve this question
    
you can always drop into a new shell by running the binary, ex: /bin/bash or /bin/ash, etc. –  Tim Jan 20 '12 at 14:03
    
/bin/bash /tmp/transferNames.bin & not help , the same problem –  Eytan Jan 20 '12 at 14:11
    
I also run the ( /tmp/transferNames.bin ) & from bash script and this give the same runing –  Eytan Jan 20 '12 at 14:12
2  
is it possible the script is waiting on user input? does it work with /tmp/transferNames.bin < /dev/null &. Does it do anything that requires a tty? If you later put the script into the foreground with "fg", does the process complete? Can you strace it? –  stew Jan 20 '12 at 14:46
    
What does the script actually do? –  Rilindo Jan 20 '12 at 14:56

1 Answer 1

up vote 0 down vote accepted

I think that your script is expecting something from standard input like stew said and thus it is pausing when you launch it with & because when in background, standard input is closed by the shell.

If you need to launch that script on the server and do something else with that shell or just shutdown your pc and go home you can try with SCREEN program. It is present packaged in most Linux distributions and you can use it like this:

screen

(new shell will open)

/tmp/transferNames.bin

The script will start as usual. You can now press this key combination: ctrl-a + d And you will be "detached" from SCREEN. You can now log out and go home, the script will still be running. When you come back and want to check the output of the script, you log in to the server and launch this command:

screen -r

that will reattach to that SCREEN session like nothing had happened at all.

Hope this helps

share|improve this answer
    
screen command not defined in linux versions -:( –  Eytan Jan 23 '12 at 0:02
    
it's usually easy to install from a package. For debian it is apt-get install screen and for CentOS it's yum install screen. It should be present in most distributions –  user842313 Jan 23 '12 at 8:45

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.