-   Linux - General (
-   -   script does not run in cron job (

kashyapvirgo 03-13-2007 03:55 PM

script does not run in cron job

My perl script does not execute from cron job.When i do mannuall it works fine.Any suggestion

Here is my cronjob line.
0 10 * * 1-3 perl /usr/ScriptsForCronjob/

mether 03-13-2007 04:02 PM

Do you run this script as root, when running manually ?. If not look for the errors in /var/log/cron and in case of yes add "root" ( without quotes ) just before perl

kashyapvirgo 03-13-2007 04:06 PM

ya i run script as root and that cronjob is also for root... still do i need to put root ahead of perl in cronjob????.

mether 03-13-2007 04:16 PM

what I suggest you is to put this cron in /etc/crontab as below :

0 10 * * 1-3 root perl /usr/ScriptsForCronjob/

And check the logs for cron.

kashyapvirgo 03-14-2007 11:12 AM

Now I put full path like 0 10 * * 1-3 /usr/bin/perl scriptpath/

stil it does not run I tried running from command prompt with /usr/bin/perl scriptpath/ and it ran fine any suggestion.

In my script i have used date command is that a problem...

now I will try 0 10 * * 1-3 root /usr/bin/perl scriptpath/ and give u update ..Let me know if u have any sol'n

kashyapvirgo 03-14-2007 01:06 PM

Nope didn't work

mether 03-20-2007 11:38 AM

Can you provide the script and also the /var/log/cron file just after its been executed ( in fail mode ) so we could look at it and dig out some details.

Clemente 03-20-2007 11:46 AM

does your crontab contain anything like

If yes, and if you use bash as terminal, does your perl script run with sh? I once had a bash related problem and thought cron is the "bad boy"...

kashyapvirgo 03-20-2007 11:55 AM

cron job -- 0 10 * * 1-3 /usr/bin/perl /usr/ScriptsForCronjob/

cron log -- Mar 19 04:23:54 ustw47ccase02 crond[1212]: (tmp.4337) ORPHAN (no passwd entry)

opendir(DIR ,"/usr/CronLog") || die("can not open dir named kashyap");
@files = readdir(DIR);
$date = `date +%y%m%d-%a`;
$ystdate = `date --date='1 day ago' +%y%m%d`;
#print "$ystdate";
foreach $files (@files)
if($files =~ /^*.txt$/)
print "$files";

if($files == $ystdate || $files == $date)
#print "$files\n ";

print "\n $files removed\n";


All times are GMT -5. The time now is 07:31 PM.