![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Running a script with cron | altamaha | Shell Programming and Scripting | 3 | 06-05-2008 08:46 AM |
| pwd & cd commands not working in shell script | perk_bud | Shell Programming and Scripting | 9 | 04-07-2008 07:11 AM |
| script not working in CRON | abhijeetkul | Shell Programming and Scripting | 5 | 07-13-2006 05:48 AM |
| running commands from script | owijust | Shell Programming and Scripting | 2 | 01-09-2006 06:12 PM |
| Running script using cron | ankurgupta | Shell Programming and Scripting | 4 | 12-12-2002 10:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
running script in cron - with ssh commands - not working
I ran an ssh command to run a script on a remote server
ssh -l <user> <servername> /path/to/script/scriptname This works fine - and the script is executed correctly. However - I put this command into a script, that I want to run from cron every hour, to execute the file on the remote server every hour, but the process appears to hang... I can see the process but it is not doing anything. It only takes 3-4 seconds to run from command line but doesnt do anything when cron submits it: root 16528 16527 0 14:46:00 ? 0:00 /usr/bin/ksh /<pathtoscript>/<script> root 16527 233 0 14:46:00 ? 0:00 sh -c /<pathtoscript>/<script> > /dev/null root 16532 16528 0 14:46:00 ? 0:00 ssh -l <user> <server> //<pathtoscript>/<script> This just hangs.... Any ideas? |
|
||||
|
Thanks for looking in to this for me.. Still havent found the issue yet..
I checked the cron log: > CMD: /pathtoscript/script.sh 2>/dev/null > root 515 c Sat May 7 13:33:00 2005 < root 513 c Sat May 7 13:33:00 2005 Only when I kill the first ssh script that is trying to run - is the cron log updated again. I waited 5 mins before killing the script that wasnt doing anything, then cron log got this entry: < root 515 c Sat May 7 13:33:53 2005 rc=143 My crontab is for my root user, which can run the script from the command line but not in cron. Key Maintainance, I think this is done from my end. I generated the keys and sent the public key to the others servers authorized_keys file. It works from command line and doesnt require password to be entered. This is why I dont know why cron cannot run it. Any other ideas? |
|
|||||
|
Try running this in a script that looks like this -
Code:
#!/bin/ksh ssh -l <user> <servername> /path/to/script/scriptname exit |
|
||||
|
This is what script looks like - I think I am already going what you are asking...
#!/usr/bin/ksh current_date=`date '+%Y%m%d'` date_time=`date '+%Y%m%d %H:%M'` ### Execute remote Scripts ### ssh -l <user> <servername> "/path/to/script/scriptname" ssh -l <user> <servername2> "/path/to/script/scriptname" ssh -l <user> <servername3> "/path/to/script/scriptname" ssh -l <user> <servername4> "/path/to/script/scriptname" ssh -l <user> <servername5> "/path/to/script/scriptname" ssh -l <user> <servername6> "/path/to/script/scriptname" |
|
||||
|
Yes - I have public-key authentication set up as root.
However - the user I am running the script as on the other server is not called root. ie. Root on my server, user1 on the other server I run the ssh script from command line on my server as root user and it works fine. (ssh -l <user1> <servername> "/path/to/script/scriptname" |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|