Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Cron for Scheduling
#1
Cron Scheduling
Scheduling your strategies, email notifications, and external programs in APM can be done using the cron (also crontab) syntax.
Please refer to this guide for another explanation (and some more advanced uses) of the cron syntax used in APM.

The cron syntax that APM is slightly different than the classic Unix cron syntax:

* * * * * * *
| | | | | | |
| | | | | | +-- Year              (range: 1900-3000)
| | | | | +---- Day of the Week   (range: 1-7 or SUN - SAT)
| | | | +------ Month of the Year (range: 1-12)
| | | +-------- Day of the Month  (range: 1-31)
| | +---------- Hour              (range: 0-23)
| +------------ Minute            (range: 0-59)
+-------------- Second            (range: 0-59)

Some notes about this format:
  • The year is optional and does not have to be included
  • The week starts on Sunday
  • You cannot put a day of the week and a day of the month. Put a ? for one of the options.
  • This format includes the second to run at, which is a mandatory field
The idea behind this format is that each cron string is 6 (or 7) numbers (or special characters) that define a schedule.

Special Characters
* : means all possible values. For example, putting * for hours would mean every hour.
? : means no value. This is used for conflicting values, such as putting a number for both the day of month and day of week. One of those values must be ?
- : is used to specify a range of numbers, i.e. 5-7 for hours would mean at 5,6, and 7am.
, : is used to specify a set of numbers, i.e. 5,7 for hours would mean at 5am and at 7am.

Here are some example cron schedules:

* * * ? * *                 Runs every second
0 * * ? * *                 Runs every minute
0 30 15 ? * *               Runs at 3:30pm every day
0 30 15 ? * MON-FRI         Runs at 3:30pm, Monday through Friday
0 30 10,15 ? * MON-FRI      Runs at 10:30am and 3:30pm, Monday through Friday
0 10 * ? * *                Runs every hour at 10 past the hour

If you are unsure about using cron, we suggest to copy one of the above schedules into APM and modify the second, minute, and/or hour fields to your needs.
Note that APM will tell you the schedule your cron string represents if you hover over the Run Strategy text.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)