Table of Contents



Cron jobs are a useful tool for automating tasks on an operating system. They allow you to schedule tasks to run automatically at specified times, such as running backups or cleaning up temporary files. Traditionally, cron jobs are running on linux systems. However, as more and more organizations migrate their workloads to the cloud, Managing cron jobs on Linux can be challenging due to their configuration and scheduling requirements and if something happens on the server, it can potentially affect the execution of cron jobs so to overcome these issues we need to find out the cloud-based solutions such as Amazon Elastic Container Service (Amazon ECS) and Amazon EventBridge.

Problem Statement

Running cron jobs in Jenkins can certainly pose some challenges, particularly when it comes to maintaining the system and managing cloud costs. Here are some of the common problems you may encounter:

Upgrading Jenkins: We cannot upgrade Jenkins to a newer version, it can cause issues with your existing cron jobs. This is because the upgrade may introduce new features or changes to the platform that can affect how your cron jobs run. To mitigate this, you will need to thoroughly test your cron jobs after each upgrade and make any necessary adjustments.

Dedicated slaves: We have dedicated slaves for our cron jobs, this can add to the cost of maintaining your Jenkins infrastructure. Dedicated slaves require their resources, which can quickly add up if you have a large number of cron jobs. Additionally, maintaining and scaling these slaves can be time-consuming and may require additional expertise.

Downtime: The cron jobs are a critical part of our system which populates the data in the production system. So it is important to have all the jobs running properly without any exception which is not the case right now as for any activity to be done on Jenkins such as upgrade Jenkins, plugins, simply restarting the Jenkins or during unexpected Jenkins’s downtime, few cron-jobs which run frequently fail or get skipped during the maintenance windows.

Solution Approach

To address these challenges, you may want to consider migrating your cron jobs to a cloud-based solution like Amazon ECS. This can help you take advantage of the scalability and cost savings that come with running your cron jobs in the cloud.

Alternatively, you can use a dedicated cron job management tool like AWS Eventbridge Rules to manage your cron jobs. These tools can help you monitor and manage your cron jobs more effectively, without the need for dedicated Jenkins slaves or the overhead of managing your infrastructure.

Based on the cost analysis conducted, it appears that migrating to a cloud-based solution like Amazon Elastic Container Service (Amazon ECS) could potentially offer significant cost savings compared to maintaining a dedicated instance setup.

In the analysis, it was found that the dedicated instance, including an Amazon EBS storage volume of 50 GB, amounted to a cost of $144. This cost likely includes factors such as the instance type, operating system, and any additional services or features utilized on the dedicated instance.

On the other hand, the cost of an Amazon ECS task was estimated to be around $50. This cost is generally lower because ECS optimized resource allocation and allows for better utilization of container instances. Additionally, Amazon ECS provides features such as auto-scaling, which can help further optimize costs by dynamically adjusting the number of instances based on demand.

While cost reduction is a significant advantage of migrating to a cloud-based solution like Amazon ECS, it's important to consider other factors as well. These may include scalability, performance, security, and the overall management and operational benefits that come with cloud-based services. Conducting a comprehensive evaluation considering all these factors will help ensure a well-informed decision that aligns with your specific requirements and goals.

Step-by-Step Procedure

Migrating your cron jobs from Jenkins to Amazon ECS by EventBridge is a straightforward process that involves the following steps:

Step 1: Create a Docker Image 

To migrate your cron jobs to Amazon ECS, you must first create a Docker image that contains your cron job code and any dependencies. Docker images provide a portable and reproducible way to package your application, making it easy to deploy across different environments. Once you have created your Docker image, you can store it in a container registry such as Amazon Elastic Container Registry (ECR). 

Step 2: Create a Task Definition 

A task definition is a blueprint that defines how your Docker container should be launched in Amazon ECS. It specifies the Docker image to use, the CPU and memory requirements, and any environment variables or port mappings required by your application. You can create a task definition using the Amazon ECS console, AWS CLI, or AWS CloudFormation

Step 3: Create a Scheduled Event in EventBridge

To trigger your cron job in Amazon ECS, you must create a scheduled event in AWS EventBridge. Scheduled events allow you to specify when and how often your cron job should run. You can create a scheduled event using the AWS EventBridge console or AWS CLI. 

 Step 4: Create a Rule in AWS EventBridge  

A rule in AWS EventBridge is a way to match incoming events to specific targets. In this case, you will create a rule that matches your scheduled event and triggers your Amazon ECS task. You can create a rule using the AWS EventBridge console or AWS CLI. 

Step 5: Test and Monitor Your Cron Job 

Once you have created your scheduled event and rule, you can test your cron job by monitoring the logs generated by your ECS task. You can also use AWS CloudWatch Logs to aggregate and analyze your logs and create alerts based on specific metrics.


Migrating your cron jobs from Jenkins to Amazon ECS by AWS EventBridge provides several benefits, including scalability, cost efficiency, and simplified management. By following the steps outlined in this blog, you can easily migrate your cron jobs to Amazon ECS and take advantage of the benefits of cloud-based solutions. Whether you are a small startup or a large enterprise, Amazon ECS by AWS EventBridge provides a scalable and cost-effective solution for running your cron jobs in the cloud.

If you are looking to streamline your AWS infrastructure, ensuring maximum performance, reliability, and cost-efficiency for your workloads, book a demo today and discover how CloudKeeper can help.

Let's discuss your cloud challenges and see how CloudKeeper can solve them all!
0 Comment
Leave a Comment

Speak with our advisors to learn how you can take control of your Cloud Cost