hi,
iam fairly new at unix.what iam trying to do is iam running a perl script through crontab.the problem is iam getting an error message on my mail.
this is the crontab file:
24 16 22 1 * perl /rishi/s-branch/perl1/perl/filecomp.pl


this is the content of my perl file
#!usr/local/bin/perl
@comp=`diff -r -s /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s-branch/perl1 /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s
-branch/doc>file1.txt`;
@text=`grep -n "Only in /tpf106" file1.txt>only.txt`;
@show=`cat only.txt`;
print @show;

Recommended Answers

All 14 Replies

don't think you're supposed to activate it by perl
the script has the interpretor line in it

change the crontab line to just the path to the script

also, is the script working when run from the shell manually?

don't think you're supposed to activate it by perl
the script has the interpretor line in it

change the crontab line to just the path to the script

also, is the script working when run from the shell manually?

script is working when i run it from the shell manually,and it runs only when i activate it through perl filecomp.pl

is the script executable?

chmod the script 755, and if you want to run it as

perl scriptname

in crontab, just be sure to give the absolute path to perl in your entry, like:

/usr/bin/perl scriptname

and it should work either way

Hope that helps :)

, Mike

25 01 23 1 * perl /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s-branch/perl1/perl/filecomp.pl>file3.txt
i have given the absolute path i have also made the script executable.its still not working.infact no perl script is running.but when i run them manually they seem to work fine.

content of filecomp.pl
#!usr/local/bin/perl
@comp=`diff -r -s /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s-branch/perl1 /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s
-branch/doc>file1.txt`;
@text=`grep -n "Only in /tpf106" file1.txt>only.txt`;
@show=`cat only.txt`;
print @show;

after some googling, seems like perl scripts have trouble running from crontab.

try to create a bash script which will launch the perl script, and make the bash script run from crontab

after some googling, seems like perl scripts have trouble running from crontab.

try to create a bash script which will launch the perl script, and make the bash script run from crontab

cant i just run it through crontab,directly.i know it happens

well it appears cron environment is not the same as the normal environment.

try to run the script with all absolute paths:
/usr/local/bin/perl /rishi/s-branch/perl1/perl/filecomp.pl

still not working

try to direct output to a logfile, let's see what the error is

its working.thanks DimaYasny & eggi

well, share the solution :)

10 07 23 1 * /usr/local/bin/perl /tpf106/data2/cis_web/cis3/cis3.11/work/rishi/s-branch/perl1/perl/filecomp.pl

the key was this part /usr/local/bin/perl.

thanks, it's good to know, since I'm switching some of my scripting to perl in a few weeks

cron does run in a different nevironment then the usual shell

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.