Current location: Hot Scripts Forums » Programming Languages » Perl » crontab not executing a perl script


crontab not executing a perl script

Reply
  #1 (permalink)  
Old 07-14-04, 12:34 AM
abtimoteo abtimoteo is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Question crontab not executing a perl script

hi, everybody!


my web host created a crontab for me with the following entry:

1 1 1-15 7 * /complete-path-to-my-cgi-bin/runThisScript.pl


the script referred to by the crontab:

print "Content-type: text/html\n\n";

open (M, "|/usr/sbin/sendmail -t")
|| die "Could not start the e-mail program: $!\n";

select (M);

print M "To: my_client\@his_domain.com\n";
print M "From: me\@my_domain.com\n";
print M "Subject: Test Script\n\n";

print M "This is to test the crontab.\n\n";

close (M);

# End of script.


some assumptions/facts:

a. the crontab was created by the root user.
b. the path to the perl script i used is correct. it is based on the cgi root environment variable.
c. the perl script is ok. i ran it using a browser with no hitches.
d. errors are sent to the root user's/web host's log, not mine. maybe this means that the crontab is really owned by the root user.


questions:

1. why is the script not being ran by the crontab? is it bcoz the file is owned by the root user and that the root user can not run my scripts.


my apologies for posting this question here. this is more of linux-sys-admin problem. but i need a quick answer and some people here are very quick to respond, aside from being patient to newbies.


thanks in advance.

arnold b. timoteo
Reply With Quote
  #2 (permalink)  
Old 07-14-04, 09:28 AM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
Hey Arnold,

There are too many reasons why the script could have failed to answer your question. You need the error message from cron to find out exactly why it failed. Do you have shell access to set up your own cron job? If you can set it up under your account then you should get the error messages.

~Charlie
Reply With Quote
  #3 (permalink)  
Old 07-14-04, 05:28 PM
bugalyzer bugalyzer is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
crontab

1. Make sure you can run the script
2. Make sure root can run the script
3. Make sure you declare the first line in the script to point to perl, it should be:
#!/path/to/perl

If root can run the script on the command line then it will run fine in cron. My guess is that root either can't execute the script or can't find perl. Check on item #3 listed above first.

Brendan
http://buildacom.com
Reply With Quote
  #4 (permalink)  
Old 07-15-04, 04:17 AM
abtimoteo abtimoteo is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
crontab not executing a perl script | required files not found

~Charlie and Brendan, thanks for the replies.

1. if forgot to indicate in my question that the script had 3 required files, namely:

require "plHTML.pl";
require "plCGI.pl";
require "Secret.pl";

2. my webhost forwarded an error msg that says:

> Can't locate plHTML.pl in @INC (@INC contains:

3. i assume that this solves the problem. crontab will run the script if the complete paths to required scripts are provided - that is:

require "/complete-path-to-my-cgi-bin/plHTML.pl";
require "/complete-path-to-my-cgi-bin/plCGI.pl";
require "/complete-path-to-my-cgi-bin/Secret.pl";

4. i am yet to know if the above will work. the crontab created for me by the root user is supposed to run/execute the script at midnight.

arnold
Reply With Quote
  #5 (permalink)  
Old 07-15-04, 09:58 AM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
You'll need to do this:

Code:
use lib qw(/complete-path-to-my-cgi-bin);
require plHTML.pl;
require plCGI.pl;
require Secret.pl;
Otherwise your script will be looking for the complete-path-to-my-cgi-bin:lHTML.pl perl lib.

~Charlie
Reply With Quote
  #6 (permalink)  
Old 05-27-08, 11:42 AM
Boraan's Avatar
Boraan Boraan is offline
Coding Addict
 
Join Date: Jul 2007
Location: Clayton, NC
Posts: 292
Thanks: 0
Thanked 1 Time in 1 Post
you know, it took me a while to think about this one and the answer as to why it isn't running is very simple. First, I doubt any admin would create a cron job for a customer and leave it devoid of any required parameters, if even to stop someone from screwing around with admin privs, so I highly doubt that it was missing.

I believe the error is in the executed line. Look at your date for execution. What day were you trying to run it?
__________________
Dexter Nelson
Techdex Development & Solutions
========================
Internet Marketing For Programmers | Free Market Research in 15 Minutes or Less
My Software: Hotscripts Softpedia software.techdex.net
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
newbie perl script to call an array in a subroutine and add 1 Arowana Perl 1 10-31-03 01:04 PM
Perl CGI wrapper script available? paulbearer Script Requests 0 09-17-03 03:18 PM
need perl script! dip Script Requests 3 09-08-03 10:57 AM


All times are GMT -5. The time now is 03:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.