Current location: Hot Scripts Forums » Programming Languages » Perl » Cron job problem


Cron job problem

Reply
  #1 (permalink)  
Old 12-06-06, 01:57 AM
sujata_ghosh sujata_ghosh is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Cron job problem

Hi to all!

I have used the following php file for testing cron job at my server. which will send email only on a specific time. here is the code of the file:
<?php

$mailto = "nilanjana@k****ij.com, sujata_atkcs@yahoo.com";
$subject = "Cron email testing";
$header = $header."From: ".sujata."\n";

$body = "Information\n";
$body = $body."-----------\n";

mail($mailto,$subject,$body,$header);

?>

file is working perfectly when i execute it on the browser. but not working from crontab.

file is there but when the time of execution its sending me a mail with following matter written on it:

/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 1:
?php: No such file or directory
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 2: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 3: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 4: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 6: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 7: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 9:
syntax error near unexpected token `$mailto,$subject,$body,$header'
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 9:
`mail($mailto,$subject,$body,$header);'

cron tab setting is as follows:

everyday at 14.00 hours the following file will be executed with following path
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php

can anyone tell me where i have made mistake? i am testing it first time. if this script using corn work well i will implement more task using this.

any help will be highly appreciated.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-06-06, 04:57 AM
speedospeedo speedospeedo is offline
Newbie Coder
 
Join Date: May 2006
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Try this:

php -q /home/...............

Quote:
Originally Posted by sujata_ghosh
Hi to all!

I have used the following php file for testing cron job at my server. which will send email only on a specific time. here is the code of the file:
<?php

$mailto = "nilanjana@k****ij.com, sujata_atkcs@yahoo.com";
$subject = "Cron email testing";
$header = $header."From: ".sujata."\n";

$body = "Information\n";
$body = $body."-----------\n";

mail($mailto,$subject,$body,$header);

?>

file is working perfectly when i execute it on the browser. but not working from crontab.

file is there but when the time of execution its sending me a mail with following matter written on it:

/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 1:
?php: No such file or directory
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 2: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 3: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 4: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 6: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 7: =:
command not found
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 9:
syntax error near unexpected token `$mailto,$subject,$body,$header'
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php: line 9:
`mail($mailto,$subject,$body,$header);'

cron tab setting is as follows:

everyday at 14.00 hours the following file will be executed with following path
/home/httpd/vhosts/k****ij.com/httpdocs/php/cronmail.php

can anyone tell me where i have made mistake? i am testing it first time. if this script using corn work well i will implement more task using this.

any help will be highly appreciated.

Thanks!
Reply With Quote
  #3 (permalink)  
Old 12-07-06, 11:18 PM
sujata_ghosh sujata_ghosh is offline
Wannabe Coder
 
Join Date: May 2006
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot!

now its working!

do i use cgi -q and perl -q for executing CGI and Perl script respectively?

Thanks once more for your help.
Reply With Quote
  #4 (permalink)  
Old 12-08-06, 02:03 AM
speedospeedo speedospeedo is offline
Newbie Coder
 
Join Date: May 2006
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Yes, but usually this depend on your host.

Quote:
Originally Posted by sujata_ghosh
Thanks a lot!

now its working!

do i use cgi -q and perl -q for executing CGI and Perl script respectively?

Thanks once more for your help.
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
Cron Job raji20 Web Servers 2 10-25-06 07:14 AM
Expert PHP Programmer Needed : Cron Job INTEL Job Offers & Assistance 5 09-06-06 07:31 PM
print "Content-type: problem with cron wannauseit Perl 3 05-01-05 09:37 AM
Cron and Perl problem erikbjork Perl 2 01-19-05 10:58 PM
Cron Job Error Tempestshade PHP 6 09-10-04 05:10 PM


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