Set task timeout for jobs

By default, each task runs for a maximum of 10 minutes:you can change this to a shorter time or a longer time up to168 hours (7 days). For tasks using GPUs, the maximum availabletimeout is 1 hour.

You can set the task timeout as described on this page. There is no explicittimeout on a job execution: when all tasks are done, the job execution is done.

The units specify a duration. You can specify the timeout duration as an integervalue in seconds, minutes, or hours. For example, to set the timeout duration as10 minutes and 5 seconds, specify the value as605 seconds.

If your job has retries enabled, the timeout setting applies to each attempt of a task.If the task attempt does not complete within this time, it will bestopped. The longer a job runs, the more likely it is to run into issues thatcause it to fail, such as downstream dependency failures, out of memory errors,or infrastructure issues. We recommend enabling retries for all jobs, butespecially for jobs with long-running tasks.

Maintenance events

Jobs periodically undergo maintenance events. During a maintenance event, anyin-progress tasks are migrated from the current machine to a different machine.There is a brief pause in processing while the task is migrated.

The migration process preserves the state of the task, with one notableexception: outbound VPC network connections break during maintenance events.We recommend that you use client libraries that can handle occasional connectionresets.

Cloud Run prints out a log message every time a task starts andfinishes migrating.

Additionally, if you want to monitor or handle maintenance events in a specific way,you can catch theSIGTSTP signal, which is sent 10 seconds before a task ismigrated. After migration, the task receives aSIGCONT signal immediatelyafter the task is restarted.

The following Go sample is a function that catches these signals and prints outa log entry:

functestSignals(){sigs:=make(chanos.Signal,1)signal.Notify(sigs,syscall.SIGTSTP,syscall.SIGCONT)gofunc(){for{sig:=<-sigslog.Printf("Got Signal: %v",sig)}}()}

Required roles

To get the permissions that you need to configure Cloud Run jobs, ask your administrator to grant you the following IAM roles:

For a list of IAM roles and permissions that are associated withCloud Run, seeCloud Run IAM rolesandCloud Run IAM permissions.If your Cloud Run job interfaces withGoogle Cloud APIs, such as Cloud Client Libraries, see theservice identity configuration guide.For more information about granting roles, seedeployment permissionsandmanage access.

Set task timeout

To specify task timeout for a Cloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud RunJobs page:

    Go to Cloud Run

  2. ClickDeploy container to fill outthe initial job settings page. If you are configuring an existing job,select the job, then clickView and edit job configuration.

  3. ClickContainer(s), Volumes, Connections, Security to expand the job properties page.

  4. Click theGeneral tab.

    image

    • In theTask timeout field, specify the maximum duration for the job tasks inthe current job, and select aTime unit. You can only specify the timeout durationas an integer value insecond,minute, orhour. For example, to set aduration of 10 minutes and 5 seconds, in theTask timeout field, specify605, and select theTime unit assecond.
  5. ClickCreate orUpdate.

gcloud

  1. For a job you are creating:

    gcloudrunjobscreateJOB_NAME--imageIMAGE_URL--task-timeoutTIMEOUT

    Replace

    • JOB_NAME with the name of your job.
    • IMAGE_URL: a reference to thecontainer image—forexample,us-docker.pkg.dev/cloudrun/container/job:latest.
    • TIMEOUT with the maximum duration for the job tasks,specifying the amount of time and the units: for example,10m5s is tenminutes and five seconds.
  2. For a job you are updating:

    gcloudrunjobsupdateJOB_NAME--task-timeoutTIMEOUT

YAML

  1. If you are creating a new job, skip this step.If you are updating an existing job, download itsYAML configuration:

    gcloudrunjobsdescribeJOB_NAME--formatexport>job.yaml
  2. Update thetimeoutSeconds: attribute:

    apiVersion:run.googleapis.com/v1kind:Jobmetadata:name:JOBspec:template:spec:template:spec:containers:-image:IMAGEtimeoutSeconds:TIMEOUT

    Replace:

    • JOB_NAME with the name of your job.
    • IMAGE_URL: a reference to thecontainer image—forexample,us-docker.pkg.dev/cloudrun/container/job:latest.
    • TIMEOUT with the maximum duration for the job tasks,specifying the amount of time and the units. You can only specify timeas an integer value in seconds, minutes, or hours. For example, to seta duration of 10 minutes and 5 seconds, specify605.

    You can also specify more configuration details, such as environment variables ormemory limits.

  3. Update the existing job configuration:

    gcloudrunjobsreplacejob.yaml

Terraform

To learn how to apply or remove a Terraform configuration, seeBasic Terraform commands.

Add the following to agoogle_cloud_run_v2_job resource in your Terraform configuration:

resource"google_cloud_run_v2_job""default"{name="cloud-run-job-timeout"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{template{timeout="3.500s"containers{image="us-docker.pkg.dev/cloudrun/container/job:latest"}}}}

View task timeout settings

To view the current task timeout settings for yourCloud Run job:

Console

  1. In the Google Cloud console, go to the Cloud Run jobs page:

    Go to Cloud Run jobs

  2. Click the job you are interested in to open theJob details page.

  3. ClickView and Edit job configuration.

  4. Locate the task timeout setting in the configurationdetails.

gcloud

  1. Use the following command:

    gcloudrunjobsdescribeJOB_NAME
  2. Locate the task timeout setting in the returnedconfiguration.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.