Search code examples
google-cloud-platformcrongoogle-cloud-scheduler

Google Cloud Scheduler different frequency based on weekdays (2 lines of cron)


I have a job I want to run every 15 mins on Monday to Saturday but every 5 mins on Sunday, I tried to input the following to Cloud Scheduler but it's saying invalid format:

*/15 * * * 1-6, */5 * * * 0

Are 2 lines of cron not allowed? Do I need to create 2 identical jobs and set a different schedules for them?


Solution

  • Here's a line from GCP docs:

    You can define a schedule so that your job runs multiple times a day, or runs on specific days and months. A schedule is described using the unix-cron string format (* * * * *), which is a set of five values in a line, indicating when the job should be executed.

    Meaning, each job can only have 1 schedule. The answer to your last question is yes. If you have multiple schedules, then each of them must be configured as separate jobs.