Skip to main content
ubuntuask.com

Back to all posts

How to Specify Cron Timezone In K8s Cron Job?

Published on
2 min read
How to Specify Cron Timezone In K8s Cron Job? image

Best Kubernetes Timezone Tools to Buy in December 2025

1 Kubernetes Software - Powerful Container Orchestration Tools T-Shirt

Kubernetes Software - Powerful Container Orchestration Tools T-Shirt

  • HIGHLY EXTENSIBLE WITH ROBUST COMMUNITY SUPPORT FOR INNOVATION.
  • AUTOMATE DEPLOYMENT AND SCALING OF CONTAINERIZED APPLICATIONS EASILY.
  • DURABLE DESIGN: LIGHTWEIGHT, CLASSIC FIT, AND QUALITY DOUBLE-NEEDLE HEM.
BUY & SAVE
$19.99
Kubernetes Software - Powerful Container Orchestration Tools T-Shirt
2 Cracking the Kubernetes Interview: Discover expert tips and best practices to ace your Kubernetes technical interviews

Cracking the Kubernetes Interview: Discover expert tips and best practices to ace your Kubernetes technical interviews

BUY & SAVE
$37.99 $44.99
Save 16%
Cracking the Kubernetes Interview: Discover expert tips and best practices to ace your Kubernetes technical interviews
3 Platform Engineering on Kubernetes

Platform Engineering on Kubernetes

BUY & SAVE
$48.28 $59.99
Save 20%
Platform Engineering on Kubernetes
4 Hacking Kubernetes: Threat-Driven Analysis and Defense

Hacking Kubernetes: Threat-Driven Analysis and Defense

BUY & SAVE
$34.71 $65.99
Save 47%
Hacking Kubernetes: Threat-Driven Analysis and Defense
5 The Kubernetes Book

The Kubernetes Book

BUY & SAVE
$9.99
The Kubernetes Book
6 Mastering Kubernetes: Dive into Kubernetes and learn how to create and operate world-class cloud-native systems

Mastering Kubernetes: Dive into Kubernetes and learn how to create and operate world-class cloud-native systems

BUY & SAVE
$31.91 $54.99
Save 42%
Mastering Kubernetes: Dive into Kubernetes and learn how to create and operate world-class cloud-native systems
+
ONE MORE?

In a Kubernetes cron job, the timezone for scheduling the job can be specified by adding a timezone field in the cron job definition. The timezone should be specified in the IANA timezone format, such as "America/New_York" or "Asia/Tokyo". This allows the cron job to be scheduled according to the specified timezone, regardless of the timezone of the Kubernetes cluster. Setting the timezone in the cron job definition ensures that the job runs at the correct time, even if the cluster's timezone is different.

What is the syntax for specifying the timezone in a Kubernetes cron job?

To specify the timezone in a Kubernetes cron job, you can use the timezone field in the cron job spec. The syntax for specifying the timezone in a Kubernetes cron job is as follows:

apiVersion: batch/v1 kind: CronJob metadata: name: my-cronjob spec: schedule: "0 0 * * *" timezone: "America/Los_Angeles" jobTemplate: spec: template: spec: containers: - name: my-container image: my-image

In the example above, the timezone field is set to "America/Los_Angeles" to specify the timezone for the cron job. You can replace "America/Los_Angeles" with the timezone of your choice.

What is the default timezone for a cron job in Kubernetes?

The default timezone for a cron job in Kubernetes is UTC.

What do I need to do to change the timezone for a cron job in Kubernetes?

To change the timezone for a cron job running in Kubernetes, you can set the timezone environment variable for the container in the CronJob configuration. Here's how you can do it:

  1. Edit the CronJob YAML configuration file for your cron job.
  2. Add the following environment variable definition to your container spec:

env:

  • name: TZ value: America/New_York

Replace America/New_York with the desired timezone identifier. You can find a list of available timezone identifiers here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

  1. Save the changes to the YAML file and apply the configuration using kubectl apply -f your-cronjob.yaml.

After making these changes, your cron job will run in the specified timezone.