Jenkins as a Centralized Cron Server/Dashboard

h3.  Jenkins

{quote}Jenkins is an open source continuous integration tool written in Java.

Jenkins provides continuous integration services for software development. It is a server-based system running in a servlet container such as Apache Tomcat. It supports SCM tools including CVS, Subversion, Git, Mercurial, Perforce, Clearcase and RTC, and can execute Apache Ant and Apache Maven based projects as well as arbitrary shell scripts and Windows batch commands. The primary developer of Jenkins is Kohsuke Kawaguchi.[3] Released under the MIT License, Jenkins is free software.[4]
Builds can be started by various means, including being triggered by commit in a version control system, scheduling via a cron-like mechanism, building when other builds have completed, and by requesting a specific build URL.{quote}

h3. features :

h5. History :

Jenkins can be configured to retain logs of jobs that it has run. So You have full visibility of what’s happening with your system.

Centralized management
With Jenkins you can manage all your imortant cron  jobs centrally.You can also export all Jenkins jobs as XML and check it into a repository.

Alert only if the Jobs fails :
If you enable email for Cron , You end up with too much of emails and eventully end up ignoring them. Jenkins on other hand can be configured to alert only when a particular job fails ie. a job exits with return code other than 0.
In addition you can use the awesome Jenkins Text Finder plugin which allows you to specify words or regular expressions to look for in console output. They can be used to mark a “job” unstable. F

h5. Job dependency :

With Jenkins you can trigger one job only after the first one completes successfully. Creating a well known Dependacy structure and rely on it.

h5. Test immediately :

With Jenkins you can click Build Now and job will run immediately. Where in Cron you have wait for the specified schedule to execute.

h5. Quick  setup

Setting up jobs is easy.

h3. Pros/Cons :

* Backup and restoration becomes very handy.
* We can control the access to Jenkins based on LDAP role.
* Can have multi node Jenkins setup for failover.
* We can schedule the cron job’s with dependency i.e. start job B once Job A completes
* Each Job have its history preserved , when did it last run , when failed etc.
* The output of  each job is also captured.
* we can have email alert if the job fails.
* We must have ssh trust between Jenkins server and the target hosts.
* Need to research further.

h3. Implementation method

* h5. Jenkins External Monitor – ( Using your Existing Cron )

# Make Sure the `Jenkins External Monitor Job` plugin is installed.
# Add a New Job in Jenkins, with a type ‘Monitor an external job’ ( Pick a relevent and name and provide the brief description )
# Now on the remote server
# Make sure the Java is installed
# export the JENKINS_HOME variable JENKINS_HOME=http://host1:8080  ( You can add this info in your .bashrc or Crontab as well )
# If the security on Jenkins server is enabled and only authorized users can run a Job, then JENKINS_HOME should be:
             export JENKINS_HOME=http://user_id:password@host1:8080
# Copy below files from Jenkins server to the remote server in /root/jenkins direcorty
{code} jenkins-core-*.jar remoting-*.jar ant-[1-9]*.jar commons-io-[1-9]*.jar  commons-lang-[0-9]*.jar jna-posix-*.jar xstream-*.jar {code}

# Add below 2 lines to your crontab
export JENKINS_HOME=http://user_id:password@host1:8080
* * * * * export JENKINS_HOME=$JENKINS_HOME; java -jar /root/jenkins/jenkins-core-*.jar “Job_Name_In_Jenkins” /path_to/script 2>&1 > /dev/null

* h5. Jenkins SSH
# Make Sure the `Jenkins SSH` plugin is installed
# Add the remote hosts details in “Manage Jenkins” –> “Configure System” -> “SSH remote hosts” -> “Add“ ( fill in the details)
# Add new Job in Jenkins , with a type “Build a free-style software project”  ( Pick a relevent and name and provide the brief description )
# Now add in the details for this Job
# Source Code Management ->None
# Build Triggers -> Build periodically -> Schedule -> put a cron schedule
# Build Environment -> Execute shell script on remote host using ssh -> Select the Site added already in above step.
# provide the Pre build script and Post build script , rest all configurations are up to your own requirement.


h3. Another proposed solution: Tron

{quote}Tron is a centralized system for managing periodic batch processes and services across a cluster{quote}

h4. The good…

* Manage dependencies between batch process
* A centralized configuration for batches which run on many machines
* Start and restart services running on many machines
* Monitor and report on batch process and services

h4. Tron Architecture

* Tron is a python daemon that executes Jobs or Services across multiple Nodes.
* It is powered by SSH. Meaning Tron just needs to be installed in one centralized location and configured to remotely execute commands.
* Tron manages executing Jobs based on predefined schedules. It resolves dependencies between other jobs in a work flow. It maintains the history of job runs for later reporting. It has a flexible system for monitoring job failures.
* State and job output (stdout/stderr) are stored on disk to avoid loss due to machine failure.
* Tron communicates with command line tools, web interface, or whatever else you can dream up via a REST API.


h4. [Tron homepage|]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s