SSH Cron
Hi
I have created an ssh script with following ssh command in it. ssh -i /home/user/.ssh/sshkey -l username server cat file.txt > /home/user/Desktop/file2.txt This command works when I run it interavtively but doesn't work in cron. I have also tried using the -n and -o batchmode=yes options. When ran with cron it authenticates successfully but the command doesn't run on the server. Any help would be great. |
Most problems with Cron scripts are caused by the fact that Cron executes the scripts in a reduced shell, not the standard login shell. So something that works from the terminal or when run in a Bash script may not work when run from Cron. To resolve this, you have to give the full path to all binaries (except for the core utilities).
So for example, you would find where the ssh binary is installed: Code:
tj@T-Bird:~$ which ssh Code:
#!/bin/sh |
not a networking question. moved to linux - software.
|
Thanks for your response!
I did try using the full path it never resolved my issue but I think it put me on the right path. I executed env from cron and piped it to a file. I compared the two environments and noticed that cron actually executes in /bin/sh I think this is the bourne shell. I know there is a way of setting the environment variables but I'm not sure how to off hand how to. I will look around and try to find out how to do this. Do you think this is the correct way to approach resolving this issue. I have tried many things and can't remember having such a hard time with what seems to be a very simple task. |
All times are GMT -5. The time now is 10:35 PM. |