星期几:表示星期几。例如,星期一为 1,星期二为 2。0或 7均可表示星期日。通过数字或星期名称的前三个大写字母(例如 SUN 表示星期日)指定星期几。
此字段与 day of the month 字段一起评估为包含性 OR,除非其中一个字段被星号 (*) 标记为不受限。例如,如果将日期设置为 1,并将周几设置为 SAT,则作业会在每月的第一天和每月的每个星期六运行,即使每月的第一天不是星期六也是如此。如果星期几不受限制(设置为 *),则作业仅在每月的第一天运行。
first sunday of month 12:00
2nd,3rd tue,wed,thu of feb,aug 13:50
every wed of december 00:00
1st friday of quarter 9:00
second,4th tue,thursday of 3rd month of quarter 18:30
1,3,4,7,11,18,29 of jan,jul 12:34
03 of month 12:34
every day 09:00
every sun,tue,thu 9:00
every 48 hours
every 5 minutes
every 60 minutes on mon,wed
every minute
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Cron job format and time zone\n\nCron jobs are scheduled at recurring intervals, specified using a format based\non [unix-cron](https://man7.org/linux/man-pages/man5/crontab.5.html). You can\ndefine a schedule so that your job runs multiple times a day, or runs on\nspecific days and months. (Although we no longer recommend its use, scheduling a\njob by [creating a `cron.yaml` file](/appengine/docs/legacy/standard/python/config/cron)\nis still supported for existing jobs.)\n\nCloud Scheduler also supports scheduling jobs using a more human-readable\nformat. For more information, in this document, see\n[Alternative job format](#use-groc).\n| **Note:** If you disable the Cloud Scheduler API while a running job is scheduled and then re-enable it later, any job that failed to run in the interim runs immediately, and not at the next scheduled time.\n\nCron job format\n---------------\n\nYou can use either the Google Cloud console, the\n[Google Cloud CLI](/sdk/gcloud/reference/scheduler), or the Cloud Scheduler [REST API](/scheduler/docs/reference/rest/v1/projects.locations.jobs/create)\nto set your schedule.\n\nA schedule is defined using the unix-cron string format (`* * * * *`) which is a\nset of five fields in a line, indicating when the job should be executed.\n\nThe time fields have the following format and possible values, and must follow\nthis order: \n\n```bash\n|------------------------------- Minute (0-59)\n| |------------------------- Hour (0-23)\n| | |------------------- Day of the month (1-31)\n| | | |------------- Month (1-12; or JAN to DEC)\n| | | | |------- Day of the week (0-6; or SUN to SAT; or 7 for Sunday)\n| | | | |\n| | | | |\n* * * * *\n```\n\n- **Minute:** indicates how far past the top of the hour your job runs, in\n minutes. For example, if the minute is set to `0`, then the job runs at the\n top of the hour (because that is 0 minutes after the hour). So if the hour\n is 8:00 AM, the job runs at 8:00 AM.\n\n- **Hour:** indicates how far past midnight your job runs, in hours\n (rounded down to the nearest hour, because remaining minutes are indicated\n in the `minute` field). Midnight is `0` and noon is `12`. For example, if\n the hour is set to `0`, then the job runs in the midnight hour (because that\n is 0 hours after midnight).\n\n- **Day of the month:** indicates the calendar date of the month. For example,\n `1` for the first day of the month. Cloud Scheduler does not\n support `L` to mean the last day of the month.\n\n- **Month:** indicates the month. Specify the month number or the first three\n letters of the month name in uppercase. For example, `1` for January, or\n equivalently, `JAN`.\n\n- **Day of the week:** indicates the day of the week. For example, Monday is\n `1` and Tuesday is `2`. Either`0`or `7` can indicate Sunday. Specify the day\n of the week either by number or by the first three letters of the weekday\n name in uppercase (for example `SUN` for Sunday).\n\n - This field is evaluated as an inclusive `OR` with the `day of the month` field, unless one of these fields is marked as [unrestricted](#unrestricted) by the asterisk (`*`). For example, if the day of the month is set to `1` and the day of the week is set to `SAT`, the job runs on the first day of the month **and** on every Saturday of the month, even if the first day of the month is not a Saturday. If the day of the week is unrestricted (set to `*`), the job runs only the first day of the month.\n\n### Matching all values\n\nTo match all values for a field, use the asterisk: `*`. When a field is set to\nthe asterisk, the field matches all valid values for that field whenever the\nother field conditions are satisfied. Setting a field to the asterisk is\nsometimes referred to as leaving the field *unrestricted*, because it is not\nrestricted to a specific value.\n\nHere are two examples in which the minute field is left unrestricted:\n\n- `* 0 1 1 1`: the job runs every minute of the midnight hour on January 1st and Mondays.\n- `* * * * *`: the job runs every minute (of every hour, of every day of the month, of every month, every day of the week, because each of these fields is unrestricted too).\n\nThe asterisk is equivalent to a special case of a [range](#range), where the\nrange starts at the first valid value for the field, and ends at the last valid\nvalue for the field (for example, `0-59` for the minute field).\n\n### Matching a range\n\nTo match a range of values, specify your start and stop values, separated by a\nhyphen (`-`). Don't include spaces in the range. Ranges are inclusive. The\nfirst number must be less than the second number. If you are using abbreviated\nnames for the month or weekday (for example, `JAN` instead of `1` for the first\nmonth of the year), the first value must come earlier in the month or week than\nthe second value.\n\nThe following equivalent examples run at midnight on Mondays, Tuesdays,\nWednesdays, Thursdays, and Fridays (for all months):\n\n- `0 0 * * 1-5`\n- `0 0 * * MON-FRI`\n\n### Matching a list\n\nLists can contain any valid value for the field, including [ranges](#range).\nSpecify your values, separated by a comma (`,`). Don't include spaces in the\nlist.\n\nExamples:\n\n- `0 0,12 * * *`: the job runs at midnight and noon.\n- `0-5,30-35 * * * *`: the job runs in each of the first five minutes of every half hour (at the top of the hour and at half past the hour).\n\n### Skipping values in a range\n\nYou can skip values in a [range](#range) by specifying a rate at which to step\nthrough the range. This is sometimes referred to as using a *step function* (or\nstep *value* or *rate expression* ). To do so, specify the range, followed by the\nforward slash (`/`) and the rate at which you want to skip through the range.\n\nYou can use the asterisk (`*`) to indicate the range of all values for the field.\nWhen you use the asterisk, the first value in the range is: 0 for the minute,\nhour, and day of the week (Sunday) fields, and 1 for day of the month and the\nmonth fields.\n\nThe step value cannot be larger than the largest possible value for the field.\nThe default step is 1, so the step function `/1` is the same as not using a step\nfunction at all.\n\nExample ranges that use step functions:\n\n- `*/2`: this is a valid step function for any field. For the minute field, it\n matches 0, 2, 4, ... , 58. For the hour, it matches 0, 2, 4, ... , 22. For\n the day of the month, it matches 1, 3, 5, ... , 31 (for a month with 31\n days). For the month, it matches 1, 3, 5, ... , 11. For the day of the week,\n it matches 0, 2, 4, 6.\n\n- `0-12/2`: this is a valid step function for the minute and hour fields. It\n matches 0, 2, 4, ... , 12.\n\nExample schedules using step functions:\n\n- `*/2 * * * *`: the job runs every two minutes.\n\n- `0 0-12/2 * * *`: the job runs every two hours, on the hour. The first run is\n at midnight. The last run is at noon.\n\n### Sample schedules\n\nThe following table shows some sample cron job schedules and their description:\n\nTime zone\n---------\n\nYou can select the time zone for evaluating the schedule either in the\nGoogle Cloud console (on the **Create a job** page, select a **Timezone** from\nthe list), or through the `gcloud`\n[`--time-zone`](/sdk/gcloud/reference/scheduler/jobs/create/http) flag when you\ncreate the job.\n\nThe value of this field must be the time zone abbreviation used in the\n[tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).\nThe default time zone is `UTC`.\n\nFor some time zones, daylight saving time can cause jobs to run or not run\nunexpectedly. This is because Cloud Scheduler runs on wall clock\ntime. In instances where a time can occur twice (such as the case when clocks go\nbackwards) and your job is scheduled at this time, your scheduled job might\nobserve execution anomalies.\n\nIf your job requires a very specific cadence, you might want to consider\nchoosing a time zone that does not observe daylight saving time. Specifically,\nUTC is recommended for Cloud Scheduler to avoid the problem\ncompletely.\n\nAlternative job format\n----------------------\n\nYou can use a more human-readable time specification format known as groc that\nprovides an alternative to cron expressions.\n\nNote that when specifying a job schedule using groc, you must use either the\n[gcloud CLI](/sdk/gcloud/reference/scheduler) or make a direct\nrequest to the\n[Cloud Scheduler API](/scheduler/docs/reference/rest/v1/projects.locations.jobs/create).\n\nFor example, some recurring events might be awkward to specify using cron like\nthe \"third Tuesday of every month.\" In such cases, you can instead use\nconstructs like the following examples: \n\n first sunday of month 12:00\n 2nd,3rd tue,wed,thu of feb,aug 13:50\n every wed of december 00:00\n 1st friday of quarter 9:00\n second,4th tue,thursday of 3rd month of quarter 18:30\n 1,3,4,7,11,18,29 of jan,jul 12:34\n 03 of month 12:34\n every day 09:00\n every sun,tue,thu 9:00\n every 48 hours\n every 5 minutes\n every 60 minutes on mon,wed\n every minute\n\nFor more information about the syntax, see\n[Defining the cron job schedule](/appengine/docs/legacy/standard/python/config/cronref#defining_the_cron_job_schedule).\n\nWhat's next\n-----------\n\n- [Changing the default region or zone](/compute/docs/regions-zones/changing-default-zone-region)\n- [View available regions and zones](/compute/docs/regions-zones/viewing-regions-zones)"]]