running script in cron - with ssh commands - not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting running script in cron - with ssh commands - not working
# 15  
Old 05-13-2005
From your logs, it is clear that the login is taking place:
Quote:
debug1: try pubkey: //.ssh/id_rsa
debug1: read SSH2 private key done: name rsa w/o comment success 1
debug1: ssh-userauth2 successfull: method publickey
The problem is probably with the command/script that you are running on the remote system. What are you running on the remote system? Can you change the remote command to something like 'touch /tmp/testfile' - basically anything to confirm that login is taking place on remote system?
# 16  
Old 05-13-2005
Thanks for the reply.

Just tried that. Basically i changed the script on the 2 remote servers to just touch a file in a directory on the remote server.

I then let cron run the script on my server to execute the script with the change above.

The file was created on the remote server 1 but hasnt got to the 2nd server yet- as far as my server is concerned, its still executing the remote script on server1.. when I do a ps -ef | grep for the script I get the following:

bash-2.05# ps -ef | grep daily
root 27707 27701 0 10:43:00 ? 0:00 ssh -v user@server1 /pathtoremotedir/script.sh root 27701 27698 0 10:43:00 ? 0:00 /usr/bin/ksh /localserver/script.sh root 27698 231 0 10:43:00 ? 0:00 sh -c /localserver/script.sh > /tmp/sshcron 2>&1


The last few lines in my debug after this are:
debug1: cb_fn 2677c cb_event 91
debug1: channel 0: rcvd close
debug1: channel 0: full closed2
debug1: channel_free: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i8/0 o128/0 fd -1/-1)

debug1: channel_free: channel 0: dettaching channel user


Idea's?
# 17  
Old 05-13-2005
we have all 3 variants of your cron jobs in our cron tables and they all work fine ...

if the command runs normally on the command line but doesn't run properly through cron --- i don't think the issue is with the keys itself (of course, i could be wrong too) ... you may have a process that is looking for input or at least checking stdin/stdout/stderr or having the incorrect path or checking some environment variable that is not being set in your script prior to it running in cron ... maybe you can run a script in cron that just records the output from "env" and then you can compare that to the output of "env" in your interactive login ...

btw, you might want to check both the local and the remote scripts ...
# 18  
Old 05-13-2005
I tried this now. I compared cron env and interactive env. There were differences so I set these in my script to be set before I run remote ssh... No difference in processing script - I still hit the same issue.

I also checked the env settings on the remote server when I run the script from cron or int - only difference is the port that it used when SSH connects to execute the script. I am at a loss...
# 19  
Old 05-13-2005
in that case, try echoing all the variables and their values on the remote script to a file you can read when it is run from cron ... see if the same variables and values are showing up in the interactive run ... from what i gather from all the posts, there's a line in your remote script that's making it hang --- my experience says this is most likely something that needs to read a file ...

btw, what does the remote script do?
# 20  
Old 05-13-2005
They all appear to be the same.

I was getting the remote script to check processes running etc.
But I have removed all of this and changed the remote script to just touch a file... thats all. And it still hangs.. although the file is created the ssh cron job on my side appears to be hanging...
# 21  
Old 05-13-2005
it seems the remote script is not exiting properly ... do you have an exit on the last line of the remote script? ... the ssh connection is probably staying open because the shell your script was running in is still open ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Commands not working with ssh remote login

Hi Friends, I am unable to run our application commands on remote server using ssh (passwordless login enabled). But the same command running with telent perl script. please suggest. SSH: C:/bin>ssh -l monitor tl04cp01 exec "/home/monitor/123" /home/monitor/123: viewlog: not found. ... (7 Replies)
Discussion started by: suresh3566
7 Replies

2. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Shell Programming and Scripting

Running Commands on a Remote Linux Server over SSH

Hello, I'm trying to create a ksh script to ssh to a remote server, enter the password and a couple commands. For security reasons I have changed the login, password and ip in my example. #!/bin/ksh ssh -t -t username@12.5.5.3 << EOF password cd bin pwd EOF When I run it. It... (5 Replies)
Discussion started by: seekryts15
5 Replies

4. Shell Programming and Scripting

Crontab - entry not working , cron job not running

I have put a cron entry in oracle user for taking hot backup every wednesday@ 2.30 AM and have given the cron entry 30 02 * * 3 /u01/vijay/hotbackupcron 2>&1 >> /u01/vijay/hotbackup.log also find below the script inside hotbackupcron, i have put in env variables as well ... (13 Replies)
Discussion started by: vijaymec50
13 Replies

5. Shell Programming and Scripting

How to automatically run commands after SSH and SUDO not working?

I'm working on a script to SSH and SUDO as (sap user sidadm) then automatically run commands that the sidadm user can run such as R3trans -v, tp, etc.. I can SSH without password and SUDO.. but the commands don't run after I SSH and SUDO to the sidadm user...here is the commands that I've... (2 Replies)
Discussion started by: icemanj
2 Replies

6. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

7. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

8. Shell Programming and Scripting

Running script and commands through SSH

Hello All, I am trying to run some simulations through SSH from my mac on our university SOLARIS system. My problem is that whenever I want to execute a command I get an error which says "Invalid argument". Maybe I should explain more what I want to do and what I did. Firstly I installed a... (10 Replies)
Discussion started by: Apfik
10 Replies

9. Shell Programming and Scripting

Running php from cron - working up to a point

Hi there, I am struggling to try and work out what is going wrong with a cron job i have running daily which opens up an imap mailbox and extracts a rar file to a directory on the web server. The script works ok when run manually, and when it is running from cron, I can see that it opens up the... (2 Replies)
Discussion started by: nicky77
2 Replies

10. Shell Programming and Scripting

Cron job giving error while running SSH command

Hi All, The script which i am using to SSH to remote server is working fine when i run is using ./ but when cron runs it it gives error that "ssh: not found" please help!!! (3 Replies)
Discussion started by: visingha
3 Replies
Login or Register to Ask a Question