cron | a cron library for go | Cron Utils library

 by   robfig Go Version: v3.0.1 License: MIT

kandi X-RAY | cron Summary

kandi X-RAY | cron Summary

cron is a Go library typically used in Utilities, Cron Utils applications. cron has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Cron V3 has been released!.

            kandi-support Support

              cron has a medium active ecosystem.
              It has 11403 star(s) with 1515 fork(s). There are 205 watchers for this library.
              It had no major release in the last 6 months.
              There are 85 open issues and 252 have been closed. On average issues are closed in 92 days. There are 36 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of cron is v3.0.1

            kandi-Quality Quality

              cron has 0 bugs and 0 code smells.

            kandi-Security Security

              cron has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              cron code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              cron is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              cron releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.
              It has 2258 lines of code, 120 functions and 14 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cron
            Get all kandi verified functions for this library.

            cron Key Features

            No Key Features are available at this moment for cron.

            cron Examples and Code Snippets

            Schedule tasks using cron expression
            javadot img1Lines of Code : 5dot img1License : Permissive (MIT License)
            copy iconCopy
            @Scheduled(cron = "0 15 10 15 * ?")
                public void scheduleTaskUsingCronExpression() {
                    long now = System.currentTimeMillis() / 1000;
                    System.out.println("schedule tasks using cron jobs - " + now);
            The cron trigger .
            javadot img2Lines of Code : 4dot img2License : Permissive (MIT License)
            copy iconCopy
                public CronTrigger cronTrigger() {
                    return new CronTrigger("10 * * * * ?");
            Schedule a task using externalized cron expression .
            javadot img3Lines of Code : 4dot img3License : Permissive (MIT License)
            copy iconCopy
            @Scheduled(cron = "${cron.expression}")
                public void scheduleTaskUsingExternalizedCronExpression() {
                    System.out.println("schedule tasks using externalized cron expressions - " + System.currentTimeMillis() / 1000);

            Community Discussions


            How to fix SageMaker data-quality monitoring-schedule job that fails with 'FailureReason': 'Job inputs had no data'
            Asked 2022-Feb-26 at 04:38

            I am trying to schedule a data-quality monitoring job in AWS SageMaker by following steps mentioned in this AWS documentation page. I have enabled data-capture for my endpoint. Then, trained a baseline on my training csv file and statistics and constraints are available in S3 like this:



            Answered 2022-Feb-26 at 04:38

            This happens, during the ground-truth-merge job, when the spark can't find any data either in '/opt/ml/processing/groundtruth/' or '/opt/ml/processing/input_data/' directories. And that can happen when either you haven't sent any requests to the sagemaker endpoint or there are no ground truths.

            I got this error because, the folder /opt/ml/processing/input_data/ of the docker volume mapped to the monitoring container had no data to process. And that happened because, the thing that facilitates entire process, including fetching data couldn't find any in S3. and that happened because, there was an extra slash(/) in the directory to which endpoint's captured-data will be saved. to elaborate, while creating the endpoint, I had mentioned the directory as s3:////, while it should have just been s3:///. so, while the thing that copies data from S3 to docker volume tried to fetch data of that hour, the directory it tried to extract the data from was s3://////////(notice the two slashes). So, when I created the endpoint-configuration again with the slash removed in S3 directory, this error wasn't present and ground-truth-merge operation was successful as part of model-quality-monitoring.

            I am answering this question because, someone read the question and upvoted it. meaning, someone else has faced this problem too. so, I have mentioned what worked for me. And I wrote this, so that StackExchange doesn't think I am spamming the forum with questions.



            How to throttle my cron worker form pushing messages to RabbitMQ?
            Asked 2022-Feb-21 at 09:22

            We have micro service which consumes(subscribes)messages from 50+ RabbitMQ queues.

            Producing message for this queue happens in two places

            1. The application process when encounter short delayed execution business logic ( like send emails OR notify another service), the application directly sends the message to exchange ( which in turn it is sent to the queue ).

            2. When we encounter long/delayed execution business logic We have messages table which has entries of messages which has to be executed after some time.

            Now we have cron worker which runs every 10 mins which scans the messages table and pushes the messages to RabbitMQ.


            Let's say the messages table has 10,000 messages which will be queued in next cron run,

            1. 9.00 AM - Cron worker runs and it queues 10,000 messages to RabbitMQ queue.
            2. We do have subscribers which are listening to the queue and start consuming the messages, but due to some issue in the system or 3rd party response time delay it takes each message to complete 1 Min.
            3. 9.10 AM - Now cron worker once again runs next 10 Mins and see there are yet 9000+ messages yet to get completed and time is also crossed so once again it pushes 9000+ duplicates messages to Queue.

            Note: The subscribers which consumes the messages are idempotent, so there is no issue in duplicate processing

            Design Idea I had in my mind but not best logic

            I can have 4 status ( RequiresQueuing, Queued, Completed, Failed )

            1. Whenever a message is inserted i can set the status to RequiresQueuing
            2. Next when cron worker picks and pushes the messages successfully to Queue i can set it to Queued
            3. When subscribers completes it mark the queue status as Completed / Failed.

            There is an issue with above logic, let's say RabbitMQ somehow goes down OR in some use we have purge the queue for maintenance.

            Now the messages which are marked as Queued is in wrong state, because they have to be once again identified and status needs to be changed manually.

            Another Example

            Let say I have RabbitMQ Queue named ( events )

            This events queue has 5 subscribers, each subscribers gets 1 message from the queue and post this event using REST API to another micro service ( event-aggregator ). Each API Call usually takes 50ms.

            Use Case:

            1. Due to high load the numbers events produced becomes 3x.
            2. Also the micro service ( event-aggregator ) which accepts the event also became slow in processing, the response time increased from 50ms to 1 Min.
            3. Cron workers follows your design mentioned above and queues the message for each min. Now the queue is becoming too large, but i cannot also increase the number of subscribers because the dependent micro service ( event-aggregator ) is also lagging.

            Now the question is, If keep sending the messages to events queue, it is just bloating the queue.

   - While reading this page, i found out that rabbitmq won't even accept the connection if it reaches high watermark fraction (default is 40%). Of course this can be changed, but this requires manual intervention.

            So if the queue length increases it affects the rabbitmq memory, that is reason i thought of throttling at producer level.

            1. How can i throttle my cron worker to skip that particular run or somehow inspect the queue and identify it already being heavily loaded so don't push the messages ?
            2. How can i handle the use cases i said above ? Is there design which solves my problem ? Is anyone faced the same issue ?

            Thanks in advance.


            Check the accepted answer Comments for the throttling using queueCount



            Answered 2022-Feb-21 at 04:45

            You can combine QoS - (Quality of service) and Manual ACK to get around this problem. Your exact scenario is documented in This example is for python, you can refer other examples as well.

            Let says you have 1 publisher and 5 worker scripts. Lets say these read from the same queue. Each worker script takes 1 min to process a message. You can set QoS at channel level. If you set it to 1, then in this case each worker script will be allocated only 1 message. So we are processing 5 messages at a time. No new messages will be delivered until one of the 5 worker scripts does a MANUAL ACK.

            If you want to increase the throughput of message processing, you can increase the worker nodes count.

            The idea of updating the tables based on message status is not a good option, DB polling is the main reason that system uses queues and it would cause a scaling issue. At one point you have to update the tables and you would bottleneck because of locking and isolations levels.



            How to run a R script twice a day?
            Asked 2022-Feb-08 at 23:31

            I had a R script configured to run via cron every day at 10am



            Answered 2022-Feb-08 at 20:25

            You still can use your original line, just change 10 to 10,22.



            Express + Sequelize: hanging the app on connection
            Asked 2021-Dec-26 at 11:52

            I have an app with postgres as db, sequelize, and express, and whenever it receives a db query, it just stays there forever, no logging or anything I run postgres in a container which I can connect to through GUI normally When I swapped it for sqlite, it worked perfectly the application

            here is the relevant piece of code



            Answered 2021-Dec-12 at 05:49

            I think it is your "".

            If local, it should be just "localhost:5432". If deployed server is remote, it should be a certain IP address XXX.XXX.XXX.XXX:5432. If deployed server is home network, it should be "192.168.0.XXX:5432".

            Check your postgres network configuration



            CloudScheduler 403 Permission denied while creating
            Asked 2021-Dec-22 at 05:07

            I am trying to create a Cron job programmatically in the CloudScheduler Google Cloud Platform using the following API explorer.

            Reference: Cloud Scheduler Documentation

            Even though I have given the user Owner permission and verified it in Policy Troubleshooter that it has, I am still getting the following error.



            Answered 2021-Dec-16 at 14:42

            The error is caused by using a service account that does not have an IAM role that includes the permission An example role is roles/cloudscheduler.admin aka Cloud Scheduler Admin. I have the feeling that you have mixed the permission of the service account that you use with Cloud Scheduler (at runtime, when a job triggers something) and the permission of the account currently creating the job (aka your account for example).

            You actually need two service accounts for the job to get created. You need one that you set up yourself (can be whatever name you like and doesn't require any special permissions) and you also need the one for the default Cloud Scheduler itself ( which is managed by Google)

            1. Use an existing service account to be used for the call from Cloud Scheduler to your HTTP target or you can create a new service account for this purpose. The service account must belong to the same project as the one in which the Cloud Scheduler jobs are created. This is the client service account. Use this one when specifying the service account to generate the OAuth / OICD tokens. If your target is part of Google Cloud, like Cloud Functions/Cloud Run update your client service account by granting it the necessary IAM role (Cloud function invoker for cloud functions and Cloud Run Invoker for Cloud Run).The receiving service automatically verifies the generated token. If your target is outside of Google Cloud, the receiving service must manually verify the token.

            2. The other service account is the default Cloud Scheduler service account which must also be present in your project and have the Cloud Scheduler Service Agent role granted to it. This is so it can generate header tokens on behalf of your client service account to authenticate to your target. The Cloud Scheduler service account with this role granted is automatically set up when you enable the Cloud Scheduler API, unless you enabled it prior to March 19, 2019, in which case you must add the role manually.

            Note : Do not remove the service account from your project, or its Cloud Scheduler Service Agent role. Doing so will result in 403 responses to endpoints requiring authentication, even if your job's service account has the appropriate role.



            Spring Batch cannot Load the JobBuilderFactory in my integration test
            Asked 2021-Dec-21 at 15:57

            I have a configuration that successfully works and loads cell line data and publishes to various recipients in a cell line topic. It works fine, but when I try to load the JobLauncherTestUtils and JobRepositoryTestUtils, I get an error which says that the JobBuilderFactory is not found. As you will see from my configuration, I do load the JobBuilderFactory and StepBuilderFactory using Lombok which delegates to Spring. Like I said all that works fine but the test Here is the test configuration yaml file




            Answered 2021-Dec-21 at 15:57

            We encountered the same issue when we added a new scheduled job configuration

            How it has been addressed:

            1. Create the JobLaunchUtils (similar to yours)



            AFTER parameter not recognized as part of CREATE TASK
            Asked 2021-Oct-31 at 06:16

            I've created a task and verified that it exists using SHOW TASKS. I'm now trying to create a subtask using the AFTER parameter of CREATE TASK, but I'm getting the following error: invalid property 'AFTER' for 'TASK'. I can't find any documentation on why this is happening. I think my syntax is correct; it appears to match Snowflake's documentation. This is my code:



            Answered 2021-Oct-31 at 06:16

            The equal sign should be removed AFTER = NIGHTLY_1:



            K8S EKS 1.21 trigger Cronjob manually
            Asked 2021-Oct-13 at 09:34

            Ever since I upgraded my EKS cluster to v1.21, I get the following error when triggering Cronjobs manually:



            Answered 2021-Oct-11 at 13:31

            Please upgrade your kubectl to 1.21 as well.



            Docker Cron does not start: "unknown flag: --rm"
            Asked 2021-Oct-07 at 08:23

            Experienced issue:

            The command * * * * * $(command -v docker) docker run --rm -it --env-file=/home/ubuntu/.env buy 10 ADA won't start. This is tested within the files

            • crontab -e
            • sudo crontab -e
            • sudo nano /etc/crontab

            The log E-Mail always prints :



            Answered 2021-Oct-07 at 08:23

            The solution is simple: I had to remove both -it and the second docker statement.

            Working command: * * * * * $(command -v docker) run --rm --env-file=/home/ubuntu/.env buy 10 ADA --yes

            The appended -yes will automatically execute the purchase without asking for confirmation.

            #Kudos to @MarkoE for helping me to solve my problem!



            Github Action is not Running on Push, only on schedule
            Asked 2021-Sep-28 at 20:32

            Based on this article, I am trying to generate a repo that runs everytime y push, but also every 4 or 8 hours. as seen by the action history, only one of them was successful, and only on a Mac Machine:

            But my goal is to run it on at ubuntu-latest, windows-latest and macos-latest to check the code in all OS. One final goal is to make it so that the message of the scheduled pushs is updated in xxx date. This is my latest code EDITED on sept 23 which can be seen in this repo:



            Answered 2021-Sep-28 at 19:10

            Objective: To run it on at ubuntu-latest, windows-latest and macos-latest to check the code in all OS:


            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install cron

            You can download it from GitHub.


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone robfig/cron

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Cron Utils Libraries


            by robfig


            by node-schedule


            by agenda


            by kelektiv


            by mtdowling

            Try Top Libraries by robfig


            by robfigGo


            by robfigGo


            by robfigJava


            by robfigGo


            by robfigGo