The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to call a shellhaving sql script from cronjob azum Shell Programming and Scripting 3 07-10-2008 06:22 AM
cronjob inside the script namishtiwari Shell Programming and Scripting 3 02-04-2008 04:35 AM
How to run a script as different user inside cronjob in solaris. csg_user SUN Solaris 11 12-15-2007 02:49 PM
help help cronjob problem with script bucci Shell Programming and Scripting 4 02-10-2007 12:38 AM
Shell script not running thru Cronjob gauravshrinivas Shell Programming and Scripting 8 11-03-2006 06:17 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Jan 2008
Posts: 9
Question cronjob to run perl script

Hi all
Recently i had finished a perl script. When i run manually, the script work fine.
But when i wanted to put the script in cron, it didn't get the same output as it run manually. I felt that it only execute the script until certain line then it stop as i see most of the related files didn't update after the script run by cron. Below is the cron i put

0,30 * * * * perl /home01/user/cheah/trigger_resend/complete.pl >/dev/null 2>&1


Did anyone can help on this?
Thanks very much...........
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 4 Weeks Ago
ynilesh's Avatar
Registered User
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 162
Quote:
0,30 * * * * perl /home01/user/cheah/trigger_resend/complete.pl >/dev/null 2>&1
- Did u try to use absolute path pf perl binary like, "/usr/bin/perl".
- Remember all your standard output/error you are redirecting to null.
by the wat what output should you expect ? where do you expect it?

- nilesh
Reply With Quote
  #3 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Jan 2008
Posts: 9
i havent try the absolute path.
What do you mean by "Remember all your standard output/error you are redirecting to null"
The output i meant is that i expected the script will generate 5 files after it being execute. But when using cron, it only generate one of the file, feel like the script processing half way
Reply With Quote
  #4 (permalink)  
Old 4 Weeks Ago
ynilesh's Avatar
Registered User
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 162
Did you find anything in cron log ?
I assume your script has executable permissions. I tried following simple code in my host,

Code:
#!/bin/bash
for i in 1 2 3 4 5
do
	touch file_$i
	echo "File generated : file_$i"
done
with these crontab settings,

Quote:
10 21 * * * /root/gen_file.sh > /dev/null 2>&1
This is working for me....

- nilesh
Reply With Quote
  #5 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Mar 2008
Location: Bay Area California
Posts: 63
When you execute from your account there is an ENVIRONMENT. When you execute from cron there is no built-in environment and if you need anything like paths, etc. you have to specify it in your script, e.g.

$ENV{PATH} = "/x/y/z"; or what ever...

my $list_var;
open(HNDL, ">/some/simple/file.txt");
foreach $list_var ( sort keys %ENV )
{
print HNDL "$list_var -- $ENV{$list_var}\n";
}
close HNDL;

Try that from both your command line and from cron and see what the difference is in your environments. When you run from cron you might be missing something you will need to specify...
Reply With Quote
  #6 (permalink)  
Old 4 Weeks Ago
broli's Avatar
Registered User
 

Join Date: Dec 2007
Location: Argentina
Posts: 148
take out the stdout a<nd stderr rediction, wait until it runs, and read the mail for the user in which you are executing that
(you need a mta)
Reply With Quote
  #7 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Aug 2008
Posts: 2
Hi Airwalker83,
If you haven't tried, you may put this as the first line of your perl script:
#!/usr/bin/env perl

and edit your crontab as:
0,30 * * * * /home01/user/cheah/trigger_resend/complete.pl >/dev/null 2>&1

assuming your script is executable.
----------------------
If this doesn't solve your problem, you may try to put the following line as the first line of your script :
. /home/(username)/.bash_profile
to set the necessary environment in the script because of the reasons "quine" mentioned and leaving the crontab as your original post.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0