DEV Community

Cover image for Why Jenkins is the Superior Choice Over Cronjobs for Scheduling Tasks
leandronoijo
leandronoijo

Posted on

Why Jenkins is the Superior Choice Over Cronjobs for Scheduling Tasks

TL;DR: After integrating Jenkins into our task scheduling, the improvement in efficiency and visibility has been phenomenal. Jenkins not only simplifies logging and running diverse tasks but also harmonizes environment management and integrates with Grafana for insightful data visualization. If you're interested in exploring this setup, check out my ready-to-run Docker setup for Jenkins-Grafana, complete with dashboard and plugins, available at leandronoijo/jenkins-grafana.

Premise

As I embarked on modernizing the digital infrastructure of a company, I was greeted by a daunting array of over two dozen services and 100+ scheduled tasks, spread across various technologies and operating systems. The setup was a chaotic blend of Linux cronjobs, Windows Scheduled Tasks, and an outdated job scheduler. My initial task was to bring some semblance of order to this chaos, which led me to implement Grafana. This was a strategic move to monitor our services, though not specifically for the scheduled tasks. It provided us with valuable insights but didn't fully address the complexity of our scheduling needs.

The real game-changer came with the need to create a new scheduled task. we saw an opportunity to modernize the scheduling infrasctructure, but we needed a tool that could seamlessly integrate various job types, including PHP, EXE, bash, and batch files. I needed a solution that was adaptable yet robust, offering not just execution but also critical monitoring capabilities like alerting and logging - prefferably over grafana, that we already started getting used to. This is where Jenkins entered the picture. What does it offer?

Logs Logs Logs!

Every output from each run is neatly logged, bringing together all job logs in one centralized hub. This effortless aggregation means no rewriting code for the sake of logs. This alone helped us save countless time.

Cross-Platform Mastery

Jenkins is a cross-platform maestro, with it's slaves\workers feature. Whether it's handling different versions of PHP or managing bash, batch, or .exe files, It does it all under one roof.

Environment File Management: Centralized and Simplified

With Jenkins, environment file management is a walk in the park. Changes in passwords or IP addresses are now a centralized affair, all within Jenkins' dashboard. It's like having a single, easy-to-access drawer for all your important keys. I'm not gonna miss hunting different enviroment files in all kinds of formats in all kinds of servers

Deployment-Free Operations

Jenkins brings a new era of simplicity by pulling code directly from Git repositories. This eliminates the need for traditional deployments, allowing Jenkins to run the latest code with ease. It’s like having an auto-update feature for your scheduled tasks. Not useful in all cases, I know. still... highly addictive

Pipelines: Choreographing Task Sequences

Jenkins isn't limited to individual scheduled tasks; it can orchestrate multiple tasks in a synchronized sequence. This allows for complex workflows where subsequent tasks are triggered only after the successful completion of preceding ones.

Integration with Grafana

Each Jenkins run can be exported to InfluxDB, a data source compatible with Grafana. This integration allows for the creation of comprehensive dashboards and alerts in Grafana, enabling cross-referencing of job failures with system errors.

User-Friendly GUI: Empowering the Non-Technical

Jenkins boasts a GUI that facilitates job reruns by non-technical personnel, like QA testers or support staff. While not always a best practice, this feature is invaluable for businesses that operate at the intersection of technology and other sectors.

Open Source Ecosystem: A Universe of Possibilities

Open Source Community: A Wealth of Resources
Jenkins, as an open-source platform, is like a treasure trove of innovation. It's not just a tool but a community-driven ecosystem, rich with plugins and solutions. This means you're not just using a product; you're part of a collaborative, ever-evolving journey, with the freedom to tailor it to your specific needs.

Wrap Up

In conclusion, after several weeks of integrating Jenkins into our workflow, the transformation has been remarkable. The ease and efficiency it has brought to managing scheduled tasks is nothing short of impressive.

For those who are intrigued and want to explore this setup. I've put together a repository on GitHub that offers a ready-to-run Docker setup for Jenkins and Grafana, complete with a dashboard and plugins.
You can find it here: leandronoijo/jenkins-grafana.

Finally, I'm curious to hear from others. Are you using Jenkins for scheduled tasks? What has your experience been like?

Top comments (0)