Script that Redirect SSH output via cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that Redirect SSH output via cron
# 1  
Old 06-14-2008
Script that Redirect SSH output via cron

Hi,

I have a script that's being called via a crontab which is a wrapper script that creates a log for the script that gets executed. Within the script that gets executed, it also run's subscripts. I've been able to get everything to work .. but the issue is one of the subscript that goes out and does a set of remote ssh connections to run a local script on servers, the output currently is being re-directed back to a file local to the system of execution, the problem is when the cron run's I know the output is being generated but it does not redirect to the local file. The file gets generated but they're all blank. I've tried to troubleshoot each script at a time and if I run the wrapper script manually, everything works, but when cron executes the script outputs these 0byte files.

I've tried:

ssh root@$i /tmp/subscript.sh >> /local/file
ssh -n root@$i /tmp/subscript.sh >> /local/file
ssh root@$i /tmp/subscript.sh &> /local/file
ssh root@$i /tmp/subscript.sh > /local/file 2>&1

I've tried many different method but I've just been left with manually running the wrapper script few times out of the day vs. having it automated.

I don't know how else I could troubleshoot or figure a way to re-direct the output from the remote ssh connection back to a local file that works under a crontab?? Any suggestions?
# 2  
Old 06-14-2008
To direct the result of remote script on a remote file:
Code:
ssh root@$i "/tmp/subscript.sh >> /remote/file"

To direct the result of remote script on a local file:
Code:
ssh root@$i "/tmp/subscript.sh" >> /local/file

# 3  
Old 06-14-2008
Interesting .... I'll give this a try on Monday morning. Thanks
# 4  
Old 06-14-2008
And loging as root through ssh is bad! Smilie
# 5  
Old 06-14-2008
Unfortunately this has been discussed and for now, that is the method of getting the info we need. We looked at a local service account but there were some against it. I agree, it should be a local service account and utilizing sudo for specific commands if require.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect script output to file after grep

i have simple program that generate log file 1 line every sec, i need to do grep for specific record then redirect to another file. #!/bin/bash for i in `seq 1 20`; do echo $i sleep 1 done ./test.sh |egrep "5|10|15" 5 10 15 r ./test.sh... (2 Replies)
Discussion started by: before4
2 Replies

2. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

3. Programming

How to redirect the output of a shell script to a file?

hi, i have a html form which call a perl program, this perl program calls a shell script. <html> <head> <title>demo</title> </head> <body> <form name="frm1" action="/cgi-bin/perl_script.pl" method="post"> <input type="text" name="fname"> ... (1 Reply)
Discussion started by: Little
1 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Solaris

Script redirect command output failed, why?

Hi, I put a for loop in a script to eject backup tapes from the robot. The command echo' output goes to the log file without problem, but command vmchange's output does not go to the log file although it's working fine. It still displays on the screen. I've tried '2>&1 1>$log', but nothing changed.... (5 Replies)
Discussion started by: aixlover
5 Replies

6. Shell Programming and Scripting

Redirect the output in shell script for tftp

I've been using tftp in one of my file #!/bin/bash filename1="config1h.txt" filename2="config15.txt" hostname="test.com" tftp $hostname <</dev/null get $filename1 get $filename2 quit EOF My output looks like this # ./test3.sh tftp> Received 1262 bytes in 0.0 seconds tftp> Received... (2 Replies)
Discussion started by: LavanyaP
2 Replies

7. Red Hat

Cron task output is 0, script output is OK

I have the following cron task set to run every 15 minutes to ascertain how many users are in the system and append the result to the log. /home/pronto/cus/whoisinc >> /home/pronto/cus/whoisin.log This is the whoisinc script date +"%d-%m-%Y,%k:%M,Pronto Users,`prowho -s | grep -v... (1 Reply)
Discussion started by: scottm
1 Replies

8. Shell Programming and Scripting

stdout redirect is working buy direct script exec but not in cron

Hi @ all :) i made a very little shell script witch is working well when i'm launching it directly like with ./script but when i'm launching it by cron tab it work at half only. the part of the script witch are not working are: #!/bin/sh apt-get updade apt-get -s upgrade >>... (5 Replies)
Discussion started by: calibal
5 Replies

9. Programming

Redirect input and output to a shell script?

Dear All: I am trying to do something that (I thought) was relatively straightforward, but my code snippet does not seem to work. Any suggestions? Thank you Sincerely yours Misha Koshelev #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include... (0 Replies)
Discussion started by: misha680
0 Replies

10. Shell Programming and Scripting

Redirect bg process output to within the script

Hi, I have a process running in the background, which throws up some output to the terminal when I run my script. How can I read this output from my script? Thank you. (5 Replies)
Discussion started by: Theju
5 Replies
Login or Register to Ask a Question