SSH Connection drops - but does my script keep running?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH Connection drops - but does my script keep running?
# 1  
Old 10-27-2010
Question SSH Connection drops - but does my script keep running?

Hello there.

I'm fairly new to Linux, but I am connecting via SSH and PuTTY to a remote server, and I am running a fairly heavy MySQL script in a PHP page.

Our connection here is dodgy to say the least and I get continuous disconnections.

My question is, when I get disconnected, does my script carry on, or does it end after doing the query it was on when I get disconnected.

The problem I have, is that the first thing the PHP script does is run a big query that takes upto 10 minutes to complete, before looping through all the records.

The big query is the bit its on when I get disconnected, and I don't know whether the script is getting to the loop or not...

Thanks, Chris
# 2  
Old 10-27-2010
Hi,
A disconnection usually sends a signal (HUP = hangup) to your script. Unless your script takes care of this signal (e.g. uses the trap command) it should stop after finishing the query.
The most common way to protect a script from receiving the HUP-signal is to start it using the nohup command:
Code:
nohup /path/to/script

Input and output are redirected when you use nohup.
This User Gave Thanks to cero For This Post:
# 3  
Old 10-27-2010
Thanks mate. I'm running it like that now, and we'll see what happens...
# 4  
Old 10-27-2010
You can also use screen ,which permits a reconnection to the running process.
# 5  
Old 10-27-2010
Thanks frans.

cero - your solution worked. Many thanks, you may have stopped me going home and boiling my own head.

I was trying to run

Code:
php Collection.php -d &

But it just wouldn't have it for some reason...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies

2. UNIX for Advanced & Expert Users

How keep running a program n an another computer via a connection ssh when the connection is closed?

Hi everybody, I am running a program on a supercomputer via my personal computer through a ssh connection. My program take more than a day to run, so when I left work with my PC I stop the connection with the supercomputer and the program stop. I am wondering if someone know how I can manage... (2 Replies)
Discussion started by: TomTomGre
2 Replies

3. Red Hat

SSH connection drops in 5 minutes

Hi, Here is the issue: Any SSH connection to this server drops in 5 minutes. # date Wed Jul 18 17:11:27 GMT 2012 (Note: use GMT) # grep Alive /etc/ssh/sshd_config #TCPKeepAlive yes ClientAliveInterval 60 ClientAliveCountMax 100 # ssh -V OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul... (9 Replies)
Discussion started by: aixlover
9 Replies

4. Shell Programming and Scripting

ssh connection through shell script with no interruption

Hi all, I need ssh in shell script. My requirement is: - Take user_name and password from user (in PHP) - Pass this to shell script which will: - connect via ssh - Run sql query - Pass the results back in PHP - Put the results to website. I know PHP has libraries for ssh and ftp, but... (3 Replies)
Discussion started by: shekhar2010us
3 Replies

5. Shell Programming and Scripting

Mysql command after a SSH connection (Script)

Hi all, Im new at scripting and i need to run a few commands at work every hours so i decide to make a script but on 1 of the steps i have a the follwoing problem: The command i do is this: #!/bin/bash ssh root@asdasd001 'mysql -h A-db-1 -uroot -password --execute "show slave status"'... (3 Replies)
Discussion started by: Aparicio
3 Replies

6. Shell Programming and Scripting

Duh, can I quit an ssh connection withOUT stopping a program running?

here's the sitch: remote freeBSD device. I am ssh'd in as root and running cgsecurity's TESTDISK program. Testdisk will take DAYS to scan this multi-terabyte RAID. Can I quit my terminal or ssh connection, disconnect from the remote computer, come back to it later and NOT stop or interrupt the... (3 Replies)
Discussion started by: jccbin
3 Replies

7. Shell Programming and Scripting

how to terminate ssh connection without terminating script

Hi all, I connect with SSH connection to remote machine in the script and ı want to logout at half of the script then continue to script. If ı write exit in the script it terminates script not SSH connection. How can i do that please help me (1 Reply)
Discussion started by: fozay
1 Replies

8. Shell Programming and Scripting

ssh connection script

Hi all, I'm writing a script that chooses the best computer available in an open lab. The script works great except every now and then there is a dead computer in the lab that begins the ssh handshaking, but freezes after the following: debug1: Offering public key: When the script happens... (2 Replies)
Discussion started by: x-375HK-x
2 Replies

9. Shell Programming and Scripting

Remote SSH Connection Using Script

Hi, I am new to Shell Scripting. Can anybody help me in writing a Script Which Could Login from a Unix box to a Remote Unix box which accepts the user credentials automatically and display the result for checking the Disk Space Utilisation (Without running any SSH agent). (1 Reply)
Discussion started by: ajith_tg
1 Replies

10. UNIX for Advanced & Expert Users

Solaris 9 remote login (ssh) drops connection

Hello All, I wonder if you can help me... Let me give you some set-up details before I ask you the question. I have Ultra-60 at home with Solaris 9 and recommended patch cluster installed. The machine is connected to a Linksys WAG54G ADSL router/modem through RJ45 ethernet cable. The... (2 Replies)
Discussion started by: ahmerin
2 Replies
Login or Register to Ask a Question