@manhng

Welcome to my blog!

Cron Jobs (best practices)

December 11, 2021 10:59

Cron Jobs (edit)

  • Load Balancing
  • Docker container
  • Prevent duplicate cron jobs running
Install-Package Cronos

NuGet Gallery | Cronos 0.7.1

Cronos - NuGet Must Haves Package

Cronos 0.7.1 on NuGet - Libraries.io

Fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions

HangfireIO/Cronos: Fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions (github.com)

Cronos is a .NET library for parsing Cron expressions and calculating next occurrences. It was designed with time zones in mind, and intuitively handles Daylight saving time (also known as Summer time) transitions as in *nix Cron.

Please note this library doesn't include any task/job scheduler, it only works with Cron expressions.

  • Supports standard Cron format with optional seconds.
  • Supports non-standard characters like L, W, # and their combinations.
  • Supports reversed ranges, like 23-01 (equivalent to 23,00,01) or DEC-FEB (equivalent to DEC,JAN,FEB).
  • Supports time zones, and performs all the date/time conversions for you.
  • Does not skip occurrences, when the clock jumps forward to Daylight saving time (known as Summer time).
  • Does not skip interval-based occurrences, when the clock jumps backward from Summer time.
  • Does not retry non-interval based occurrences, when the clock jumps backward from Summer time.
  • Contains 1000+ unit tests to ensure everything is working correctly.

Releases · HangfireIO/Cronos (github.com)

HangfireIO/Hangfire v1.7.0 on GitHub (newreleases.io)

Common Load Balancer Issues

What Is Load Balancing? How Load Balancers Work (nginx.com)

Load Balancing 101 - Learn All About Load Balancers (avinetworks.com)

Troubleshoot your Network Load Balancer - Elastic Load Balancing (amazon.com)

Troubleshoot common issues Azure Load Balancer | Microsoft Docs

Troubleshooting Internal HTTP(S) Load Balancing  |  Google Cloud

Troubleshooting Internal TCP/UDP Load Balancing  |  Google Cloud

Common Load Balancer Issues (vmware.com)

This topic discusses several issues and how to resolve them.

The following issues are common when using NSX load balancing:
  • Load balancing on TCP port (for example, port 443) does not work.
  • A member of the load balancing pool is not utilized.
    • Verify the server is in the pool, enabled, and monitor health status.
  • Edge traffic is not load balanced.
    • Verify the pool and persistence configuration. If you have persistence configured and you are using a small number of clients, you may not see even distribution of connections to backend pool members.
  • Layer 7 load balancing engine is stopped.
  • Health monitor engine is stopped.
    • Enable load balancer service. Refer to the NSX Administration Guide.
  • Pool member monitor status is WARNING/CRITICAL.
    • Verify the application server is reachable from the load balancer.
    • Verify the application server firewall or DFW is allowing traffic.
    • Ensure the application server is able to respond to the specified health probe.
  • Pool member has the INACTIVE status.
    • Verify the pool member is enabled in the pool configuration.
  • Layer 7 sticky table is not synchronized with the standby Edge.
    • Ensure that HA is configured.
  • Client connections, but cannot complete an application transaction.
    • Verify that the proper persistence is configured in the application profile.
    • If the application works with only one server in the pool (and not two), it is most likely a persistence problem.

Cron Jobs

October 29, 2021 16:30

Cron Jobs (edit)

Crontab.guru - The cron schedule expression editor (HAY HAY HAY)

How to run cron job every day in ASP.NET Core Application?

Creating a Quartz.NET hosted service with ASP.NET Core (andrewlock.net)

Hangfire – Background jobs and workers for .NET and .NET Core

Quartz.NET (quartz-scheduler.net)

dotnet-labs/ServiceWorkerCronJob: Schedule Cron Jobs using HostedService in ASP.NET Core (github.com)

Schedule Cron Jobs using HostedService in ASP.NET Core | by Changhui Xu | codeburst (HAY HAY HAY)

NuGet Gallery | Cronos 0.7.1 (HAY HAY HAY)

Releases · HangfireIO/Cronos (github.com) (HAY HAY HAY)

Schedule Background Jobs Using Hangfire in .NET Core | by Changhui Xu | codeburst (HAY HAY HAY)

HangfireIO/Cronos: Fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions (github.com)

HangfireIO/Cronos: Fully-featured .NET library for working with Cron expressions. Built with time zones in mind and intuitively handles daylight saving time transitions (github.com)

Cronos

Cron job troubleshooting guide

Schedule Cron Jobs using HostedService in ASP.NET Core (HAY HAY HAY)

Cron - Wikipedia

Một vài ghi chú về Cron Job (dotnetcoban.com)

  • .NET 5.0
  • Using System.Timers.Timer
  • Using TimeZone: Japan Standard Time (JST) is 9 hours ahead of Coordinated Universal Time (UTC)
    • TimeZone: UTC+09:00
    • Default Culture = "ja-JP"
    • For sending the Email with ja-JP
    • Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("ja-JP");
    • Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ja-JP");
  • Cronos version 0.7.1
  • AddSingleton...
  • AddHostedService...

Nuget: Cronos

Version: 0.7.1

        /// <summary>
        /// Crontab First Day of Every Month
        /// https://crontab.tech/first-Day-of-Month
        /// Crontab run at 12:00 AM of First Day of Every Month:
        ///  0 0 1 * * /path/to/your/script-or-program
        /// -------------------------------------------
        /// Crontab run at 12:30 AM of First Day of Every Month:
        /// 30 0 1 * * /path/to/your/script-or-program
        /// -------------------------------------------
        /// Crontab run at 01:00 AM of First Day of Every Month:
        ///  0 1 1 * * /path/to/your/script-or-program
        /// -------------------------------------------
        /// Crontab run at 01:30 AM of First Day of Every Month:
        /// 30 1 1 * * /path/to/your/script-or-program
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        protected static string GetCronExpression(string time)
        {
            if (string.IsNullOrEmpty(time)) return "";
            var arr = time.Split(':', StringSplitOptions.RemoveEmptyEntries);
 
            if (int.TryParse(arr[0], out int hour) && int.TryParse(arr.Length > 1 ? arr[1] : "0"out int minute))
            {
                return $"{minute} {hour} * * *";
            }
 
            return "";
        }

Cronos

Cronos là một bộ phim chính kịch kinh dị độc lập của Mexico năm 1993 do Guillermo del Toro viết kịch bản và đạo diễn với sự tham gia của Federico Luppi và Ron Perlman. Cronos là phim truyện đầu tiên của del Toro, và là phim đầu tiên trong số nhiều phim mà ông đã làm việc với Luppi và Perlman.

Chronos: Vị Thần Thời Gian Của Hy Lạp Và Thế Giới Đồng Hồ

Cronus

Cronus (tiếng Hy Lạp: Κρόνος; còn gọi Kronos)  một vị thần trong thần thoại Hy Lạp. Thần  con út của Uranus và Gaia, và  một trong 12 Titan. Vị thần Saturn trong thần thoại La Mã được coi  tương đương với Cronus.

Saturnus fig274.png

Categories

Recent posts