3

I'm a little bit confused about cron job parameters. I'm using bitnami magento installation on amazon azure. I found that if I want to run cron tasks I have to configure cron job

and there is this line

* * * * *  su daemon -c "/bin/sh /opt/bitnami/apps/magento/htdocs/cron.sh"

and I do not understand how frequently I will run ? As I understant setting my own cron task I will also have to use asterisk to set frequency. Can anyone explain how to understand this asterisk convention ?

Thanks in advance.

intentarr
  • 365
  • 1
  • 5
  • 14
  • Take a look at AOE Scheduler for Magento. With this module you can view the crons in the admin, and start them manually if needed. – SPRBRN May 08 '14 at 12:55

2 Answers2

10

* = always. It is a wildcard for every part of the cron schedule expression.

So * * * * * means every minute of every hour of every day of every month and every day of the week.

 * * * * *  command to execute
 ┬ ┬ ┬ ┬ ┬
 │ │ │ │ │
 │ │ │ │ │
 │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
 │ │ │ └────────── month (1 - 12)
 │ │ └─────────────── day of month (1 - 31)
 │ └──────────────────── hour (0 - 23)
 └───────────────────────── min (0 - 59)

The nice drawing above is provided by wikipedia

An other example:

0 * * * * -this means the cron will run always when the minutes are 0 (so hourly)
0 1 * * * - this means the cron will run always at 1 o'clock.
* 1 * * * - this means the cron will run each minute when the hour is 1. So 1:00, 1:01, ...1:59.

Marius
  • 197,939
  • 53
  • 422
  • 830
  • question, does @weekly etc work? I have always just specified the full value inside the xml <cron_expr>30 5 * * *</cron_expr> – David Manners May 08 '14 at 07:56
  • 1
    @DavidManners. I just saw that on the link I posted. I've never used it (because I never knew it's possible). If wikipedia says it works than it should. But it works only in the crontab. You cannot use it as an expression in magento crons. Take a look here to see how the cron schedule is handled Mage_Cron_Model_Schedule::setCronExpr. It splits the expression by space and expects 5 or 6 parts. – Marius May 08 '14 at 08:03
  • Thanks @Marius I knew about it from a cron side but I wasn't sure if Magento could deal with it. – David Manners May 08 '14 at 08:09
  • I'd add that you could use /5 1-2 * * to run your cron every five minutes between 1am and 2 am, that can come in handy. – Julien Lachal Apr 03 '15 at 07:44
5
Minutes [0-59]
|   Hours [0-23]
|   |   Days [1-31]
|   |   |   Months [1-12]
|   |   |   |   Days of the Week [Numeric, 0-6]
|   |   |   |   |
*   *   *   *   * 
Pradeep Sanku
  • 9,236
  • 2
  • 41
  • 73