• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cron Job Issue

New Here ,
Aug 19, 2009 Aug 19, 2009

Copy link to clipboard

Copied

Hi All,

Well this is my first query on this forum, so in case i am not following any rules or something then please guide me.

Here is what has forced me to put it here -

Q:- I want to create a cron job which will run each night at 00:01 hrs and will check for some condition through database and based on those conditions it will send the mail.

My Attempt - Till now what i have read through net and other available tutorials, that either through Admin or <cfschedule> tag, this can be achieved. I tried both but could not meet the target.

What i did was, i made a cfm page with the below code - Name of this page is CronJob.cfm

<cfschedule action="update" task="checkshipment" operation="HTTPRequest" url="http://127.0.0.1/coldfusion/support/CronProcess.cfm"

startdate="18/08/2009" starttime="03:37 PM" endtime="08:35 PM" interval="daily">

After this i run this page once so that it is registered in the neo-cron.xml file.

CronProcess.cfm is the page where i do the comparision and sending mails.

But it does not work at all.

I have tried lot of things but all in vain.

Could you please help on this. Where i am going wrong and what mistake i am doing?

I will be eagerly waiting for inputs.

Thanks a lot.

TOPICS
Advanced techniques

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 19, 2009 Aug 19, 2009

Copy link to clipboard

Copied

My first thought is that you are overusing the parameters.

If you have access to the administrator, it might be easier to schedule the task there.  It is a little clearer on which options are grouped together.  IMHO the <cfschedule....> tag is more for use when either you do not have access the the administrator, usually in shared hosting scenarios; or you have a highly dynamic task that one needs to use some type of business logic to determine when it should be scheduled.

Anyway, your use of the starttime, endtime and interval seem to be clashing to me.  Usually when you want to schedule a task to run daily you would only use the starttime, and startdate to set when the first time should be, and then the interval to say what frequency the task will run after that inital point in time.

The enddate and endtime parameters are used only if you want to this task to stop at some predefined point in the future.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2009 Aug 19, 2009

Copy link to clipboard

Copied

You might want to perform the following experiment. Comment out everything in the page CronProcess, except for the code <cfoutput>#now()#</cfoutput>. Can you open the page http://127.0.0.1/coldfusion/support/CronProcess.cfm ? I suspect you miss the port number, usually 127.0.0.1:8500.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2009 Aug 20, 2009

Copy link to clipboard

Copied

Hi IAN and BKBK, thanks a lot for the instant reply.

Well i tried, IAN what you suggested but could not meet the target.

BKBK i am able to run both the pages individually and both runs fine.

Well what i am doing now i attaching both the files.

CronJob.cfm - contains the <cfschedule> tag

CronProcess.cfm - is the page that should be executed when cron job runs.

Neo-Cron.xml - for your info.

Kindly help me out, i am really stuck.

If you guys think that <cfschedule> has got some issues then tell me how to do it through ADMIN. But my first choice is doing it through tag.

There seems to be some problem while attaching the files so i am providing the contents -

CronJob.cfm -

------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Crone Job</title>
</head>

<body>
<cfschedule action="update" task="checkshipment" operation="HTTPRequest" url="http://127.0.0.1/coldfusion/support/CronProcess.cfm" startdate="18/08/2009"
starttime="12:52 PM" interval="daily">
</body>
</html>

CronProcess.cfm -

-------------------------

<cfmail to="abc@xyz.com" from="yuppy@yahoo.com" subject="Mail Sent">
</cfmail>

Waiting for the important inputs.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 20, 2009 Aug 20, 2009

Copy link to clipboard

Copied

There is techinically no choice between using the cfscheduler tag or the Administrator. When you implement the tag, Coldfusion registers the task automatically in the Administrator anyway!

The page cronjob.cfm is a scheduler, not a presentation page. So, I would omit all the HTML. Also, the way you write dates and times might be different from how Coldfusion interprets them in your local. Using the appropriate functions prevents any amibiguity.

cronjob.cfm

==========

<cfschedule action="update" task="checkshipment" operation="HTTPRequest" url="http://127.0.0.1/coldfusion/support/CronProcess.cfm" startdate="#createdate(2009,8,18)#"
starttime="#createtime(12,52,0)#" interval="daily">

CronProcess.cfm

==============

<cfmail to="abc@xyz.com" from="yuppy@yahoo.com" subject="Mail Sent">
some meaningful message, like yadda yadda yadda
</cfmail>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 20, 2009 Aug 20, 2009

Copy link to clipboard

Copied

BKBK wrote:

There is techinically no choice between using the cfscheduler tag or the Administrator. When you implement the tag, Coldfusion registers the task automatically in the Administrator anyway!

Yes there is no technical difference.  But for somebody new to schedule tasks the form in the administrator may make it a little clearer which options are for scheduling a one off task, which are for scheduleing a task for a certain period of time and which set up one to run forever.  Just a slight difference in presentation is all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2009 Aug 21, 2009

Copy link to clipboard

Copied

Hi IAN & BKBK,

Thanks a lot for your invaluable inputs.

It has worked has for me.

The problem was, CFM page which i wanted to execute was under the directory which needed a password when run.

So i just moved it outisde that directory and it wordked fine.

Again lot of thanks to you guys.

Umesh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2009 Aug 21, 2009

Copy link to clipboard

Copied

LATEST

I really got a very instant reactions to my problem. So lot of thanks for being so quick.

I have explained what i was doing wrong in my second last reply.

Again lot of thanks.

Umesh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation