LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-13-2007, 02:55 PM   #1
kashyapvirgo
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Rep: Reputation: 0
script does not run in cron job


hi

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/scrpt.pl
 
Old 03-13-2007, 03:02 PM   #2
mether
Member
 
Registered: Mar 2007
Distribution: RHEL, Fedora, Open Suse
Posts: 151

Rep: Reputation: 31
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
 
1 members found this post helpful.
Old 03-13-2007, 03:06 PM   #3
kashyapvirgo
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
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????.
 
Old 03-13-2007, 03:16 PM   #4
mether
Member
 
Registered: Mar 2007
Distribution: RHEL, Fedora, Open Suse
Posts: 151

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

0 10 * * 1-3 root perl /usr/ScriptsForCronjob/scrpt.pl

And check the logs for cron.
 
Old 03-14-2007, 10:12 AM   #5
kashyapvirgo
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Now I put full path like 0 10 * * 1-3 /usr/bin/perl scriptpath/scrpt.pl

stil it does not run I tried running from command prompt with /usr/bin/perl scriptpath/scrpt.pl 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/scrpt.pl and give u update ..Let me know if u have any sol'n
 
Old 03-14-2007, 12:06 PM   #6
kashyapvirgo
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
Nope didn't work
 
Old 03-20-2007, 10:38 AM   #7
mether
Member
 
Registered: Mar 2007
Distribution: RHEL, Fedora, Open Suse
Posts: 151

Rep: Reputation: 31
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.
 
Old 03-20-2007, 10:46 AM   #8
Clemente
Member
 
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Ho,
does your crontab contain anything like
Code:
SHELL=/bin/sh
?
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"...
 
Old 03-20-2007, 10:55 AM   #9
kashyapvirgo
LQ Newbie
 
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
cron job -- 0 10 * * 1-3 /usr/bin/perl /usr/ScriptsForCronjob/scrpt.pl

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


#!/usr/bin/perl
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 ";
next;
}

print "\n $files removed\n";
unlink($files);
}

}
closedir(DIR);
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
How to write a script to run bitdefender antivirus as a cron job? ginda Linux - Software 1 03-10-2005 08:08 PM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
shell script fo run auto job in cron JolynnMarie LinuxQuestions.org Member Intro 0 04-28-2004 11:21 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration