Tutorials > Cron Jobs
If you wish to run automated background processes, you may wish to learn more about how to setup cron jobs, and run them. Combining cron with custom functions or scripts can give you some very nice effects. Below is a brief tutorial on the subject you may find helpful.
What is Cron?
Cron is a special service available on most servers that allows you to schedule the server to perform tasks every so often automatically. One use, is to call a special BoltWire page every so often with a function on it that indexes your site, deletes expired stamps, checks or sends mail messages, or any other tasks. Tasks can be set to run every month, week, day or minute--or anywhere in between.
If you do not know how to set up a cron job, ask your web hosting provider. Normally there is a cron icon in your control panel, which takes you to a simple form that allows you to enter a command line, and select various frequencies to run that line. The command to call a BoltWire page should look something like the following:
To use cron, simply put whatever functions you want to run automatically on a page, make sure that page is viewable to guests, and set up a cron job to call that page at the frequency you desire. You can also set up BoltWire scripts to create complex actions that can do about anything you can conceive.
- Create a function to refresh a sandbox page every half hour.
- Create various kinds of logs
- Send yourself a daily digest of site activity
- Notify yourself of recently updated pages.
- Update certain info or data variables.
- Do background indexing on your site
- Delete expired stamps
- Send out a certain number of newsletters every few minutes
- Check an email account and import new messages to your site
- Send a card to members once each day on their birthday
- Periodically delete temp pages no longer needed
- Purge member accounts that have been inactive for a year
No doubt you can think of other creative uses of cron.
By default, site indexing is now handled automatically in the background and does not require cron. On a large and active site, you may prefer to use cron, as a updating a large index can affect page load times. The downside is changes will only be indexed at the time of the next cron job.