Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script with pipes does not work from cron

Status
Not open for further replies.

vman123

Programmer
Sep 24, 2004
2
US
have a script that works from command but not from cron. opens a pipe to read select from mysql then opens multiple processes to read output from that select via STDIN. can somebody lend a hand? thanks

my $logdir = "piperead.$str.log";
open LOG, ">$logdir";

eval {
open WP, '-|', "/apps/mysql/bin/mysql -hkzdevreporter1.nwk.iwon.com -preporter -ureporter -D mysearch_retention -q -e 'select entry_week, week_num, cbid,live, searching, entry_week_total, tot_search, ta, part from mysearch_part_track' ";
open RP1, '|-', "perl bin/retention_mywebsearch.pl " or die "can't fork retention_mywebsearch.pl -$! \n";
open RP2, '|-', "perl report.pl" or die "can't fork report2.pl -$! \n";
open RP3, '|-', "perl bin/retention_by_product_n2f.pl 1>/dev/null " or die "can't fork retention_mywebsearch.pl -$! \n";
open RP4, '|-', "perl bin/retention_by_product.pl 1>/dev/null " or die "can't fork retention_mywebsearch.pl -$! \n";
open RP5, '|-', "perl bin/retention_mywebsearch_part.pl 1>/dev/null" or die "can't fork retention_mywebsearch.pl -$! \n";
open RP6, '|-', "perl bin/retention_mywebsearch_specific_track.pl 1>/dev/null" or die "can't fork retention_mywebsearch.pl -$! \n";

};
if ( $@ ) {
print LOG $@;
print LOG "\n";
close LOG;
exit 1;
}

#skip the header;
my $header = <WP>;

while (<WP>){
print RP1 $_;
print RP2 $_;
print RP3 $_;
print RP4 $_;
print RP5 $_;
print RP6 $_;

}

close WP;
close RP1;
close RP2;
close RP3;
close RP4;
close RP5;
close RP6;
close LOG;
 
Could be a permissions thang ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Hi,
I've experienced the same problem with Oracle.
Is it the same user which runs the script manually and wich owns the cron ?
It could be that mysql environment variables are defined only in user's profile, so when running from crontab you must explicitely define your mysql variables or run .profile.
BR,
Zephan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top