0

I have a script on a remote server (bServer) which SSH's to a central server (lets call is cServer) and kicks a script which further SSH's to 2 other server (server13 / server14), a script is ran on each of these servers which produces a file.

I have DSA SSH's keys set up from cServer to server13/14. cServer will then pull the produced files from server13/14 and then bServer will pull them from cServer.

This works perfectly when ran manually.

However... When I schedule the job on bServer in CRON, the file from server14 is not pulled onto cServer.

Here's what's more interesting: the file from server13 DOESN'T TRANSFER from cServer to bServer when the the ssh OR scp command to server14 is present in the same script.

If I have them in separate scripts, server13 file get back to bServer fine but the file for server14 is only PRODUCED, and not transferred at all back to cServer.

Both server13 and server14 are running the same build of SunOS.

I've read so many different solutions for similar problems, but haven't found any resolution.

This has to be the most annoying problem I've ever came across. Any help would be most appreciated!

cardycakes
  • 431
  • 1
  • 4
  • 12
  • 1
    You should ask on http://superuser.com/ but I remember that you have to copy the public keys on servers if you want to use scp in script. – kmas Oct 28 '13 at 13:26
  • Can you provide the crontab entry for the job your running? – Signal15 Dec 03 '14 at 17:46

1 Answers1

0

When executing a job via cron, you are not retaining your environment. If you have already logged into the remote server as the user who owns the cron script, you may wish to try, for the purpose of diagnosis, to run the same script by means of the at command, which instead does.

If you have put your commands in an executable script called my_script, the following command

at -f my_script 0936.00 will execute the command my_script at 9 hours 36 minutes. If that works, you will know that in cron you are missing some essential component of your environment.

Ravi K M
  • 77
  • 4
  • 16