Search code examples
google-cloud-platformgoogle-cloud-scheduler

Get status of scheduler job from python


I have a scheduled job running on Cloud Scheduler, and I would like to get its status ("Success", "Failed") from python. There is a python client for cloud scheduler here but can't find documentation on how to get the status.


Solution

  • You can get the status with the library like that

        from google.cloud.scheduler import CloudSchedulerClient
        client = CloudSchedulerClient()
        print(client.list_jobs(parent="projects/PROJECT_ID/locations/LOCATION"))
    

    I chose list_job but you can also use get job.

    In the JSON object that you receive, you have a status field. If empty (meaning no error), the latest call was in success. If not, it was in error and you have the GRPC error code in the field.