Cron Jobs to Schedule the task

Posted on by By admin, in Pentaho | 0

Cron is a job scheduling utility present for Linux Users.It runs based on commands specified in a cron tab. With cronjobs, we can determine which task has to run and what time we want the task to execute.

Please refer the below example:

Here I’m trying to execute a pdi job.

1. First I have created a .sh file in which I have saved the PDI( kjb) job details

#!/bin/bash
#set -vx
export JAVA_HOME=/opt/java/jdk1.8.0_291
JOB="example.kjb"(job name)
DIR="/usr/local/scripts/kettle-jobs"(path to job directory)
TOOL_BIN_PATH="/usr/local/data-integration/"(tool path used to run job)
TOOL="kitchen.sh"(tool used to run job)
LOG="/home/gopi/ETLLogs/example.log"(logs) 
cd ${TOOL_BIN_PATH}
./${TOOL} -file=${DIR}/${JOB} -level=Basic >> ${LOG}

2. Open the crontab using the command below

Cron Jobs to Schedule the task

crontab -e   this will open a tab where we save the commands. 
10 9 * * 3 /usr/local/scripts/kettle-jobs/example.sh(.sh file path)

Save the above command in crontab and the job will run at scheduled time(in the above example job will run at 9:10 on every Wednesday).

Cron Jobs to Schedule the task

crontab format:

* * * * * file to execute
First * is to specify the minutes (0-59)
Second * is to specify the hour (0-23)
Third * is to specify day of month (1-31)
Fourth * is to specify month (1-12)
Fifth * is to specify day of week (0-6)

We can also use special symbols like * , – / to specify the multiple values in the field
For example

30 08,09 * 1 * sample.sh : runs every 1st day of month on 8:30 and 9:30

*/30 * * 1 * sample.sh : runs every 30 min on 1st of every month

General Cron Job Syntax:

  • crontab -e: to install or update job in crontab
  • crontab -l: list crontab entries
  • crontab -r: delete our crontab file
  • crontab -v: show up the last time we have edited our crontab file

Thank You,
Soni Sammani
Helical IT Solutions

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments