Scheduled Apex - CronExpression Question

I am currently having difficulty in understanding the CronExpression parameter for `System.schedule()` method.

As per doc it says the syntax is

"Minutes, Hours, Day of month, Month, Day of week, optional Year"

http://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_crontrigger.htm

I scheduled a job from UI and when I queried on the CronTrigger field for CronExpression I got

"0 0 9 ? * 1,2,3,4,5,6,7"

The job above is scheduled to run at 9:00 AM on all days. I could infer "all days" is reflected by "1,2,3,4,5,6,7" but then it does not match with the doc's syntax reference.

I am lil confused.

Also can someone let me know what should be the CronExpression for hourly job (runs at every hour..say 9:00 AM, 10:00 AM, 11:00 AM etc).

If you have a look at the System.Schedule method documentation here it provides a detailed breakdown of how the CRON expression can be configured. To go through yours piece by piece (numbers in brackets on second line are a reference for us to use):

`````` 0   0   9   ?   *  1,2,3,4,5,6,7
{1} {2} {3} {4} {5} {6}
``````

{1} Number of seconds past the minute, so 0 here i.e. start of the minute.

{2} Number of minutes past the hour, 0 again so start of the hour.

{3} Hour of the day, 9 so 9 am. Uses 24 hour notation so 21 = 9pm

{4} Day of the month, ? means no specific value, only available for day of the month and day of the week. Should use ? on one when detailing the other

{5} Month (if we only want to run on 1st Jan say, this would be 1). * indicates all values, i.e. every month

{6} Day of the week. 1,2,3,4,5,6,7 here specifies days 1,2,3,4,5,6,7 in the week. We could also write this string as MON-FRI or preferably as * to indicate all values.

So your job reads to run at "0 seconds past 0 minutes of the 9th hour on no specified day of the month for every month of the year for every day of the week"

CronExpression for hourly job: '0 0 * * * ?'