Scheduled tasks

161 views
Skip to first unread message

tquill

unread,
Aug 15, 2012, 4:40:05 PM8/15/12
to cfwh...@googlegroups.com
I'm just starting to look into scheduled tasks in the coldfusion adminstrator.  Does cfwheels have any scheduled tasks ability, or can something like that only be used in the CFadmin?
 
Basically, if I want to run some code at regular intervals, is there a cfwheels function for that?  I searched the docs for scheduled tasks, but I don't remember seeing much.
 
Thanks for thelp.

Cathy Shapiro

unread,
Aug 15, 2012, 4:54:10 PM8/15/12
to cfwh...@googlegroups.com
There is a cfschedule in coldfusion
> --
> You received this message because you are subscribed to the Google Groups
> "ColdFusion on Wheels" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cfwheels/-/t8nVJiLE_NcJ.
> To post to this group, send email to cfwh...@googlegroups.com.
> To unsubscribe from this group, send email to
> cfwheels+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cfwheels?hl=en.



--
Flash Pro Design
4646 Poplar, Suite 517
Memphis, TN 38117

Phone: (901) 767-8767
Fax: (901) 685-9054

http://www.flashprodesign.com

tpet...@gmail.com

unread,
Aug 15, 2012, 5:47:48 PM8/15/12
to cfwh...@googlegroups.com
Cathy is correct, using the cfschedule tag is the way to go.

the best way to implement it in wheels is to just add the cfschedule tags calls into your events/onapplicationstart.cfm 

also when using the cfschedule tag, make sure to use the UPDATE action to create the tasks this way it will only create them if they don't exist on a reload.

Thorsten Eilers

unread,
Dec 4, 2012, 4:57:38 AM12/4/12
to cfwh...@googlegroups.com
I would like to administrate the scheduled task of my cfwheels app in the admin section of the app.

Do I have to mirror the params for every scheduled task in the database and have an ORM model for it, or is it better to use no table for it, because coldfusion saves all necessary data for scheduled tasks themself.
I would then need a tableless model, I guess?

Andy Bellenie

unread,
Dec 4, 2012, 5:11:09 AM12/4/12
to cfwh...@googlegroups.com
Depends how complex they are and if you want to have database logging. If you do go the database route, Ben Nadel has thought it out pretty thoroughly here: http://www.bennadel.com/blog/2237-Storing-Your-ColdFusion-Scheduled-Tasks-In-The-Database.htm

A tableless model would be another route, as you could setup validations for the various arguments of cfschedule.


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/fNB7qoKqds0J.

Thorsten Eilers

unread,
Dec 4, 2012, 5:36:25 AM12/4/12
to cfwh...@googlegroups.com
Thanks Andy.
Why is almost always someone lightyears ahead of me? ;-)
Now I have to read Bens article in my lunch break.

Thorsten Eilers

unread,
Dec 4, 2012, 7:42:15 AM12/4/12
to cfwh...@googlegroups.com
OK, I will try to integrate and extend Bens approach in wheels.

In events/onapplicationstart.cfm I would like to call my MainScheduledJob executed every 3 minutes (180) seconds.
It shall call a function in my controller: scheduledTasks.cfc.

<cfschedule action = "update"
    task = "MainScheduledTask" 
    operation = "HTTPRequest"
    url = "http://127.0.0.1/scheduledTasks/scheduledTasks.cfm"   
    interval = "180"
    resolveURL = "no"
    publish = "no"       
    requestTimeOut = "160"
    priority="5"
    mode="server"
    retryCount="3">

My question:
How can I call the function in my controller?
How do I have to modify
url = "http://127.0.0.1/scheduledTasks/scheduledTasks.cfm"  ?

Andy Bellenie

unread,
Dec 4, 2012, 7:44:13 AM12/4/12
to cfwh...@googlegroups.com
The URL should map to a normal Wheels path, e.g. /tasks/run/[key]

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/ch2_rihdQaQJ.

Thorsten Eilers

unread,
Dec 4, 2012, 8:00:09 AM12/4/12
to cfwh...@googlegroups.com
OK, thanks. Did it.
How do I prevent spiders or other users to call this function via their browser?
How to restrict the call only to my cfwheels app? Do I have to pass a password via the URL? How to prevent the URL being spidered?

<cfschedule action = "update"
    task = "MainScheduledJob" 
    operation = "HTTPRequest"
    url = "/scheduledJobs/getScheduledJobs"   

Andy Bellenie

unread,
Dec 4, 2012, 8:05:54 AM12/4/12
to cfwh...@googlegroups.com
<cfif cgi.remote_addr eq "127.0.0.1">



--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfwheels/-/D-wczNcrEhMJ.

Thorsten Eilers

unread,
Dec 4, 2012, 8:20:05 AM12/4/12
to cfwh...@googlegroups.com
Oh, how nice and simple. ;-)
Reply all
Reply to author
Forward
0 new messages