Magento has a powerful built-in engine to perform cronjobs, let’s see how we make them work.
First of all, we need to declare a crontab in our OS. Let’s say we have Ubuntu ( or derived, or Debian ) and we want to run magento cronjobs every minute:
adding the line which defines that our jobs need to be scheduled for every single minute of the day:
So our environment in running Magento’s cron script every minute, but our script produces nothing: let’s do something!
Let’s say that we developed a custom module, useful for sysadmins and similar, which has a table containing the references of all our development team ( name, position, email, .. ) and we regularly want to inform our team that Magento is running properly.
So let’s modify the XML of our module, in app/code/local/MyCompany/MyModule/etc/config.xml adding the crontab reference:
1 2 3 4 5 6 7 8 9 10 11 12
So, you see that in the example above you need to edit everything between tags with:
- module name
- model name ( the model in which you’re going to write the cronjob )
- model method name ( the function that your crontab will run ) all lowercase.
So now you have to create your method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15