Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a cfm file automatically

Status
Not open for further replies.

mana2

Programmer
Aug 9, 2002
116
US
Hi,

I need to have a cfm file run at certain time intervals automatically and I'm not sure how to go about doing that.
For example, every 30 days a cfm file will run automatically(Without someone running the program) on the server to delete old records from the database.

Thanks
 
if you have got access to the CF administration pages have a look at the 'Schedule Tasks' This will allow you to create a schedule to run your CF page. You can set various options in the cf admin for this.

If you don't have access to the cf administrator then have a look at the cfschedule tag. Using the cf admin is the preferable option as it is less fidley in my opinion. This tag does the same as the CF administrator but you have to program the options that you want. like this from the cfdocs:

<cfschedule action = &quot;update&quot;
task = &quot;TaskName&quot;
operation = &quot;HTTPRequest&quot;
url = &quot; startDate = &quot;8/7/98&quot;
startTime = &quot;12:25 PM&quot;
interval = &quot;3600&quot;
resolveURL = &quot;Yes&quot;
publish = &quot;Yes&quot;
file = &quot;sample.html&quot;
path = &quot;c:\inetpub\ requestTimeOut = &quot;600&quot;>

hope this helps!

Tony
 
Yes, thank you so much. I had seen Schedule Tasks in the Administrator but didn't see the cfschedule tag.
 
Although, using the scheduler is a good solution to automate your once a month update. I think it would be better to schedule the task directly in your database using a stored procedure and an automated job or trigger.

This way if your automation fails you have a better chance of recovery within your data infrastructure.

What database are you using (Oracle, SQL Server, MySql, ect..)?

Bygs
 
I'm using SQl. I would prefer to schedule the task in the database since I don't really have access to the CF administration pages. Would I still use CFSchedule in what you described?

Thanks again.
 
If you are using MS SQL Server you can incorporate all your SQL from your .CFM into a stored procedure.

In MS SQL Server there is a management area that contains a JOB organizer which allows you to run your stored procedure(once a month, everyday, mon-fri,ect..) or run command line executables. You can use the command line to run a CFM page from the cfusion\bin directory.

Job command line syntax:
master..xp_cmdshell 'c:\cfusion\bin\cfexec c:\yourcoldfusionpage.cfm'

Like I said earlier I prefer to keep any automated procedure within the scope of the sql database because the recovery from an automation error is better and less intranet traffic.

Which means creating a sql stored procedure which can also be run from the JOB manager:
exec [server].<database>.<owner>.my_stored_proc

Hope this helps,

Bygs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top