<p>Sounds like a pretty simple custom Craft <a href="http://buildwithcraft.com/docs/plugins/introduction" rel="nofollow">plugin</a>.</p>

<p>You'd add a <a href="http://buildwithcraft.com/docs/plugins/controllers" rel="nofollow">controller</a> to your plugin and an action method and allow <a href="http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions" rel="nofollow">anonymous access</a> to it.</p>

<p>Your method would run any queries you need and save the results to an XML file on the server somewhere.</p>

<p>Then setup cron to execution the action at whatever interval you want.</p>

<pre><code>0 3 * * * curl -s -o /dev/null "http://mydomain.com/actions/myplugin/myaction"
</code></pre>

CC BY-SA 3.0
2015-10-05T17:27:25.220Z
2015-10-05T17:27:25.220Z
Brad Bell
<p>For an upcoming project one of the requests is that the client needs to be able to run a few custom queries on a specific section (queries are fixed, we know what these will be in advance) and then save the output to an xml file on the server. Bonus points if we can do this with a cron job, say daily.</p>

<p>I've been looking at several plugins (Sprout reports, Zenbu) but none really do what I need out of the box.</p>

<p>How would I go about handling this? Sorry if this question is too general, just looking for pointers on where to start. Any input appreciated!</p>

<plugin-development><cron><xml>
Running custom query save result to xml file
# Running custom query save result to xml file

(Asked by: username_0 on 2015-10-05)

For an upcoming project one of the requests is that the client needs to be able to run a few custom queries on a specific section (queries are fixed, we know what these will be in advance) and then save the output to an xml file on the server. Bonus points if we can do this with a cron job, say daily.

I've been looking at several plugins (Sprout reports, Zenbu) but none really do what I need out of the box.

How would I go about handling this? Sorry if this question is too general, just looking for pointers on where to start. Any input appreciated!

**Tags:** plugin-development, cron, xml


---

## 1 answers

### Answer by username_1 on 2015-10-05. Score: 1 | Accepted answer

Sounds like a pretty simple custom Craft plugin.
You'd add a controller to your plugin and an action method and allow anonymous access to it.
Your method would run any queries you need and save the results to an XML file on the server somewhere.
Then setup cron to execution the action at whatever interval you want.
0 3 * * * curl -s -o /dev/null "http://mydomain.com/actions/myplugin/myaction"


---

