title: Cronjob not executing the Shell Script completely
body: <p>This is Srikanth from Hyderabad.</p>
  
  <p>I the Linux Administrator in one of the corporate company. We have a squid server, So i prepared a Backup squid server, so that when LIVE Squid server goes down i can put the backup server into LIVE.</p>
  
  <p>My squid servers are configured with Centos 5.5. I have prepared a script to take backup of all configuration files in /etc/squid/ of LIVE server to the backup server. i.e It will copy all files from Live server's /etc/squid/ to backup server's /etc/squid/</p>
  
  <p>Here's the script saved as squidbackup.sh in the directory /opt/ with permission 755(rwxr-xr-x)</p>
  
  <pre><code>#! /bin/sh
  username="&lt;username&gt;"
  password="&lt;password&gt;"
  host="Server IP"
  
  expect -c "
  spawn /usr/bin/scp -r &lt;username&gt;@Server IP:/etc/squid /etc/
  expect {
          "*password:*"{
          send $password\r;
          interact;
                       }
     eof{
    exit
        }
  }
  </code></pre>
  
  <p>** Kindly note that this will be executed in the backup server that will check for the user which is mentioned in the script. I have created a user in the live server and given the same in the script too.</p>
  
  <p>When i execute this command using the below command</p>
  
  <pre><code>[root@localhost ~]# sh /opt/squidbackup.sh
  </code></pre>
  
  <p>Everything works fine till now, this script downloads all the files from the directory /etc/squid/ of LIVE server to the location /etc/squid/ of Backup server</p>
  
  <p>Now the problem raises, If i set this in crontab like below or with other timings</p>
  
  <pre><code>50 23 * * * sh /opt/squidbackup.sh
  </code></pre>
  
  <p>Dont know what's wrong, it is not downloading all files. i.e Cronjob is downloading only few files from /etc/squid/ of LIVE server to the /etc/squid/ of backup server.</p>
  
  <p>**Only few files are downloaded when cron executes the script, If i run this script manually then it is downloading all files perfectly with out any errors or warnings.</p>
  
  <p>If you have any more questions, Please go ahead to post it.</p>
  
  <p>Now i kindly request to give if any solutions are available.</p>
  
  <p>Please Please, Thank you in advance.</p>
  
  <hr>
  
  <p>thanks for your interest. I have tried what you have said, it show like below, but previously i use to get the same output to mail of the User in the squid backup server.</p>
  
  <p>Even in cron logs it show the same, but i was not able to understand what was the exact error from the below lines.</p>
  
  <p>Please note that only few files are getting downloaded with cron.</p>
  
  <pre><code>spawn /usr/bin/scp -r &lt;username&gt;@ServerIP:/etc/squid /etc/
  &lt;username&gt;@ServerIP's password:
  </code></pre>
  
  <p>Kindly check if you can suggest any thing else.</p>