title: How to execute a perl script on crontab
body: <p>I have written a perl script test.pl which uses a subroutine written in another file testing .pm. I'm able to run this script successfully manually, but when I run the same script on crontab, I get the following error<br>
  <strong><code>Can't locate testing.pm in @INC</code></strong><br>
  I have changed the permissions of both the files to execute permission and used <strong><code>"use testing"</code></strong> at the top of the script. How can I successfully run the script on crontab. </p>
  
  <p><strong><code>Crontab : */2 * * * *  PERL5LIB=$PERL5LIB:/home/test/testing.pm /home/test/test.pl &gt; /home/test/test.log 2&gt;&amp;1</code></strong></p>
  
  <p>**</p>
  
  <pre><code>test.pl  
  #!/usr/bin/perl -w
   use DBI;
   use warnings;
   use Time::Piece;
   use HTML::Entities;
   use lib '/home/test';
   use testing
  # Connecting to the database #
  my $dbh = DBI-&gt;connect("DBI:mysql:database=test;host=localhost;mysql_socket=/var/run/mysqld/mysqld.sock","root","password", {'RaiseError' =&gt; 1});
  # my $dob = '2009-04-21 00:00:00';
  my $dob = '2009-04-22 00:00:00';
  #my $dob = localtime-&gt;strftime('%Y-%m-%d %H:%M:%S');
  print "\ndob : $dob\n";
  $name="test";
  $number=1;
  $email="test@test.com"
  $id="123";
  if ($mail==0)
  {
   send_msg(0,$name,$number,$email,$aid);
  }
  if ($sms==0)
  {
   send_msg(1,$name,$number,$email,$id);
  }
  }
  sub send_msg {
     my ($type,$name,$number,$email,$id) = @_;
     $sql7 = "select Sms,email from settings where Id='$id'";
     $sth7 = $dbh-&gt;prepare($sql7);
     $sth7-&gt;execute
     or die "SQL Error: $DBI::errstr\n";
     my ($sms,$email)=$sth7-&gt;fetchrow_array();
     my $xml=testing::xml($type,$name,$number,$email,$sms,$email);    
  }
  </code></pre>
  
  <p>**</p>