Before I can go on with this tutorial I wanted you all to know that you require a medium level of expertise in either linux or a database.
What is a cronjob?
If you have been a windows user then you may have heard of a scheduled task which you can run on your windows PS. For the non geeks a scheduled task is some process you have arranged to take place at a specific time.
For e.g. A meeting you have scheduled at 3.30 PM for every friday to go over previous weeks tasks and suggest next weeks priorities
The meeting has to take place and two or more persons have agreed to it. The place has been decided and the agenda is set, so it scheduled to happen. The meeting may occur recurring over different time spans thus being a recurring schedule.
The same way a cronjob is a scheduled task on Linux based system that has to run at specific time at specific intervals to do a specific task. A cronjob uses shell scripts which is a language used by Linux system to run tasks.
A shell script can make use of any other languages such as Java, PHP etc to collect output.
What is a Trigger?
A trigger according to dicitionary.com means anything, as an act or event, that serves as a stimulus and initiates or precipitates a reaction or series of reactions.
In relation to database a trigger is a task that occurs on insert, update or delete tasks within a table. So in short whenever someone adds a new comment, or your sub editor adds a new post or someone deletes a post from your database you can have a trigger to do something. For instance email you the comment or email you the new post, or in case of deletion backup the post to a new temp table.
OK why am I talking about Cron jobs and triggers?
For every website webmaster it is quite essential to know what’s going on on their websites, also informing their subscribers, readers and commentators is quite essential.
Coming up against situations where a irate writer or sub editor decides to leave the company but thinks that he/she should also cause a bit of a loss to the company and deletes few or all posts from your database, now think of a trigger that helped you to backup data on deletes.Isn’t it a good choice using triggers.
If your hosting on a shared hosting it is not hard to create a trigger all you need is access to a database that supports triggers, if you are on a dedicated hosting then the first thing you should do is ask your technical support to create triggers for critical tables.
The only bad part about this is you will be storing a duplicate information in your database but that duplicate information can really save you from many a blushes. But if you use a discount with Dreamhost that i provide you can have access to a database and webhosting service that provides you with so and so with a cost of this.
Why Cron jobs now?
Ok so now you have all the essential plugins and all the things you require to run your website, why should you do cron jobs. Many a developers create a admin panel for you from where you can control all the actvities of the site.
Some of the activities may be
1. Sending a newsletter to all subscribers
a. Create newsletters
b. Choose required subscribers
c. Send it to them
2. Subscription Instructions
a. Find users who are not using your site for long.
b. Send them a message that they are doing so.
c. Manually delete after a specific period
Ok so as a webmaster I have to do all these things, but can I automate these yes I can. Most of today’s sites run on a Linux based system and you can find tons of scripts that does simple tasks such as checking your database and sending a email message and deleting records.
All you need is a shell script to execute themseleves, mind you, you may argue why do i spend money on getting such scripts, but mind you the time you spend on these things after the automation is nil, so you do not worry after you set up a cron job.
Coming up in the next part is how you can create a trigger on your tables.
Just to be useful I am professional Software Engineer and can help you to achieve the automations for your site you can contact me at firstname.lastname@example.org. The above post is not an advertisment but information to make your web life better, if you have any issues please use the comment form below or email me at email@example.com.