Problem with ssh termination...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with ssh termination...
# 8  
Old 08-18-2010
Why do you want iostat to continue running on the server? You are redirecting its output to a file?

In the script you can try:
#===================================
nohup iostat 1 100 1>> "iostat_output.log" 2> "iostat_output.log"
#===================================

The two arguments for iostat are:
1 number of seconds between each measure
100 number of times to measure

But be careful, if you run it twice and the first time has not yet finished, the log file will be a mess.

Regards.

---------- Post updated at 11:28 ---------- Previous update was at 11:27 ----------

Ops! An error, the line can be:

In the script you can try:
#===================================
nohup iostat 1 100 1>> "iostat_output.log" 2> "iostat_output.log" &
#===================================
# 9  
Old 08-18-2010
no im still having the same problem....i still have to press ctrl c on client server to quit.....or it quits automatically when i kill iostat on server

---------- Post updated at 09:53 AM ---------- Previous update was at 09:45 AM ----------

ssh is waiting for the termination of iostat on the destination server only then ssh exiting on its own on the client machine and comes to prompt

---------- Post updated at 10:52 AM ---------- Previous update was at 09:53 AM ----------

managed to do it by adding this to the ssh


Code:
ssh ${HOST} '/ravi/test/stat_collect.ksh start </dev/null >nohup.out 2>&1 &'



---------- Post updated at 10:53 AM ---------- Previous update was at 10:52 AM ----------

but can someone explain what i am doing here....
# 10  
Old 08-18-2010
For me the code below is executed successfully!

No Ctrl+c needed!

Code:
# cat test.sh
#!/bin/ksh
echo "Arguments: [$*]"
echo "Starting: [iostat]..."
logFile="/<FullPathToLogFile>/iostat_output.log"
nohup iostat 1 100 1>> "${logFile}" 2>> "${logFile}" &
iostat 1 5
echo "Ending: [iostat]."
exit

Look that you need to change the variable: ${logFile} to point to the path of the log file.

I validated the execution, and after the remote call finished, the "iostat_output.log" continue increasing which means the iostat command was executing still.

---------- Post updated at 13:21 ---------- Previous update was at 13:09 ----------

About the command you asked:

Code:
ssh ${HOST} '/ravi/test/stat_collect.ksh start </dev/null >nohup.out 2>&1 &'

It uses Input/Output redirection and you can find further information in the following site: Tips For Linux - Input/Output Redirection in Unix

The trick in the command is the: "&" sign, which means the script can continue to execute without needing to wait for this command finish to execute. It is the same as I sent you!

Code:
nohup iostat 1 100 1>> "${logFile}" 2>> "${logFile}" &

# 11  
Old 08-19-2010
thank you so much felipe.vinturin.....the method u suggested is also working....it was very helpful...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies

2. AIX

A question about scsi termination

http://ep.yimg.com/ay/iercomputer/ibm-39j5022-ultra320-scsi-adapter-dual-channel-pci-x-fc5736-3.gif I have bought this controller. Simple and fast question: I will put on this controller a external LTO tape,which is terminated with a terminator. I have to put another terminator on PCI-controller... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies

3. Shell Programming and Scripting

Cat termination in script

So, I'm writing a shell script to help automate a process I'm doing. Basically I want to take input from the user for 2 variables, then create a file that consists of: Variable1,Variable2 Constant1 Constant2 .. Constant2000 then run an awk script. I'm pretty new to unix though, and so... (11 Replies)
Discussion started by: Parrakarry
11 Replies

4. Shell Programming and Scripting

Catching the termination of one script

Hi I have a Shell script that needs to execute a command at the End of the excursion of other script And I cant get a handel On the trap command. And that is if the trap command Is the proper way to go this is a extract of the script MYHOST=`hostname| cut -d. -f1` echo $MYHOST ... (4 Replies)
Discussion started by: Ex-Capsa
4 Replies

5. Shell Programming and Scripting

random script termination

I'm writing a script to archive data. First, the files are all rsync'd to the archive directory via NFS mounts(I know not the most efficient, but the only choice in this situation), then I use md5sum to validate the transfers. During execution of the script, it will exit for no apparent reason. It... (6 Replies)
Discussion started by: mph
6 Replies

6. Programming

does snprintf guarantee null termination?

Hi All, I was reading the man page of snprintf function and it saids that snprintf adds a null terminator at the end of the string, but I remember once someone told me that snprintf doesn't guarantee the insertion of a null terminator character. What do you think? Does anyone have experience... (4 Replies)
Discussion started by: lagigliaivan
4 Replies

7. Programming

handling abnormal process termination

hi i m writin a program in which i keep track of all the child processes the program has generated and if a child process has an abnormal termination i need to do certain task related to that child process. for handlin child process i used waitpid: temp_cpid=waitpid(-1,&stat,WUNTRACED); ... (4 Replies)
Discussion started by: mridula
4 Replies

8. UNIX for Advanced & Expert Users

Child peocess termination.

Hello all, Here is the problem: A ksh script (let's call it abc.sh) gets kicked off from a menu program using "nohup abc.sh &". The process ID of abc.sh can be recieved (pid=$!). abc.sh runs an Oracle PL/SQL script (it creates a child process). In order to stop the abc.sh (and the child)... (5 Replies)
Discussion started by: Shaz
5 Replies

9. UNIX for Dummies Questions & Answers

Abnormal Termination errors

I'm having trouble with Abnormal Termination errors. What are they, what causes them and how can I prevent them from happening? Are they application specific? (2 Replies)
Discussion started by: bialsibub
2 Replies
Login or Register to Ask a Question