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

Different Cron Expression for day and night


Is there a way to create a cron expression to run for every half an hour during the day and every 4 hours during the night?

I am using this cron expression inside a cloud scheduler that runs the GCP cloud function.


Solution

  • I think this should do the trick:

    0,30 7-23,0-6/4 * * *
    

    So this runs on every 0th and 30th minute of the hour from 7 til 23 and then every 4th hour from 0 to 6.

    You can also have crontab.guru explain it to you.