How to Schedule a Cron Job on Google Cloud Scheduler?

Context

I have containerised a machine learning inference batch job that I am currently running on an on-prem ubuntu instance as a cron job. Basically, the cron job runs (there are a few other lines, but this is the core)

docker run $IMAGE

and this performs some inference using python.

Challenge

I want to migrate this job to the cloud using GCP infrastructure, but a bit confused about which service to use and how. Someone from Google customer team initially suggested Google Batch, but after some research I realised batch cannot support cron job at all. Then some forums/tutorials seem to support Google cloud scheduler. But after further reading it seems they trigger jobs if I hit an http endpoint. (That means hitting the http endpoint has to be established as a cron job with my on-prem infra? But why would anyone use that?)

So want to ask the SOF community on what’s the appropriate Google service to run a cron job, without myself managing an instance (and keeping it on 24*7).

For information, I have already pushed the $IMAGE to Google artefact registry. So all I need for google is to run the image with the following cron expression.

30 0 * * *
Further Details (Based on Comment)

I have a docker image in google artefact registry. The last line of the image is

# Run the script at container boot time.
CMD ["./run_manager.sh"]

This run_manager.sh performs the feature engineering, model training+inference using tensorflow and persists the result in an appropriate database. The whole thing takes about 20-25 minutes to run and then the container terminates.
I need to run this job daily, let’s say at 12.30 am every day. Currently I have this set up as a cron job on an on premise Ubuntu instance.

Requirement

Leverage Google cloud to perform this, without having to keep a VM on 24*7 just for one job. The behaviour I want is a Google cloud service to which I supply

  • The artefact URL in the artefact registry
  • The cron expression (or something equivalent)

and then GCP takes care of running the artefact/container according to the cron expression?

There is no web-service, no http-endpoint, no pub-sub here. Just a cron job.

3

Leverage Google cloud to perform this, without having to keep a VM on 24*7 just for one job.

In that scenario, you can think of using Instance Schedules through which you can start and stop your VM’s at a particular time everyday.

You can follow these steps to create instance schedule:

  1. In the Google Cloud console, go to the VM instances page.

  2. Go to VM instances

  3. Click the Instance schedules tab at the top of the page.

    Note: If you don’t see this option, create a VM instance first.

  4. Click date_range Create schedule. The Create a schedule pane opens.

  5. Enter a Name.

  6. In the Region drop-down menu, select the location for this instance schedule.

  7. Define when the instance schedule starts and stops any attached VM instances. If you need VM instances to start or stop at a specific time, schedule the operation 15 minutes earlier than needed. Make sure each start and stop operation are at least 15 minutes apart.

  8. Use either the default Start time, Stop time, and Frequency fields or, if you want to configure a more complex schedule, use cron expressions.

    Default fields: Enter a Start time, a Stop time, or both.

    In the Start time field, type or click access_time to select the time to start VM instances.

    In the Stop time field, type or click access_time to select the time to stop VM instances. In the Frequency drop-down menu at the bottom of the pane, select how often the Start time and Stop time repeat.

  9. If you want to use Cron expressions:

    To enable cron expressions, click the Use CRON expression toggle at the top of the pane.

    Enter a Start CRON expression, Stop CRON expression, or both.

    In the Start CRON expression field, enter a cron expression that describes when to start VM instances.

    In the Stop CRON expression field, enter a cron expression that describes when to stop VM instances.

  10. In the Time zone drop-down menu, select the time zone for the Start time and Stop time.

  11. Click Submit.

According to the time specified while creating the Instance Schedule, your VM would start, the cron job will be run, and then finally the VM would be stopped.

For more details check this public document, this StackOverflow thread and this article.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật