Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Command line to run jobs in unix.

  1. #1

    Question Command line to run jobs in unix.

    I just know we can run job by command line with kettle.sh. Can some please explain me what to code in kettle.sh to run the jobs in UNIX. Please give me example aswell.

    Thanks and Regards
    Amar.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,771

  3. #3
    Join Date
    Dec 2009
    Posts
    332

    Default

    Below is the script I use to call kitchen. It relies on a symbolic link to the latest version of Pentaho (which makes upgrades easier.) It enables us to specify the java version or force it within the kitchen.sh script file as needed. It logs output of each job based on the job file name and rejects the execution if I mess up the full path name.

    Script begins below:

    ## Tests for a valid parameter 1
    : ${1?PDI job file name is required as the first argument}
    : ${1:?PDI job file name cannot be empty}

    ## Set up the variables required for script and kitchen
    export JAVA_HOME=/usr/bin/java;
    _LOGROOT="/var/pdi-assets/Logs";
    _KITCHEN="/opt/pentaho/design-tools/LATEST_PDI/kitchen.sh";

    _LOGGINGLEVEL="Basic";

    if [ ! -s "$1" ];
    then
    /bin/echo "Cannot find $1";
    elif [ "${1##*.}" != "kjb" ];
    then
    /bin/echo "Only Kettle Jobs can be processed: $1";
    elif [ ! -x "$_KITCHEN" ];
    then
    /bin/echo "Cannot find executable kitchen: $_KITCHEN";
    elif [ ! -d "$_LOGROOT" ] || [ ! -w "$_LOGROOT" ];
    then
    /bin/echo "Main logging root directory set incorrectly";
    /bin/echo "_LOGROOT: ${_LOGROOT}";
    else
    ## Break first parameter into its component parts for scripting

    _JOBFULLPATH="$1";
    ##/bin/echo "Full Path: $_JOBFULLPATH";
    _JOBFILENAME="${1##*/}";
    ##/bin/echo "File Name: $_JOBFILENAME";
    _JOBDIRECTORY="${1%/*}";
    ##/bin/echo "Directory: $_JOBDIRECTORY";
    _JOBEXTENSION="${1##*.}";
    ##/bin/echo "Extension: $_JOBEXTENSION";
    _JOBFILEBASE="${_JOBFILENAME%*\.kjb}";
    ##/bin/echo "Base Name: $_JOBFILEBASE";
    _JOBFOLDER="${_JOBDIRECTORY##*/}";
    ##/bin/echo "Job Folder: $_JOBFOLDER";

    if [ ! -d "${_JOBDIRECTORY}" ];
    then
    /bin/echo "Full pathname not used properly $1"
    else

    export PATH=$JAVA_HOME/bin:.:$PATH

    _LOGFILE="${_LOGROOT}/${_JOBFOLDER}/${_JOBFILEBASE}.log";
    ##/bin/echo "Log File: $_LOGFILE";

    ## Create log file if it does not already exist
    if [ ! -e "$_LOGFILE" ];
    then
    /bin/touch "$_LOGFILE";
    fi

    ## Check if log file exists and can be written to
    if [ ! -w "$_LOGFILE" ];
    then
    /bin/echo "Unable to access writeable $_LOGFILE";
    else

    /bin/echo "-------- START --------------------------------------" >> $_LOGFILE 2>&1
    /bin/date >> $_LOGFILE 2>&1

    /bin/echo "Initiating Pentaho process ${_JOBFILENAME}" >> $_LOGFILE 2>&1

    /bin/echo "${_KITCHEN}" -norep -file="${_JOBFULLPATH}" -level="${_LOGGINGLEVEL}" >> $_LOGFILE 2>&1

    "${_KITCHEN}" -norep -file="${_JOBFULLPATH}" -level="${_LOGGINGLEVEL}" >> $_LOGFILE 2>&1

    /bin/echo "-------- END ----------------------------------------" >> $_LOGFILE 2>&1
    fi
    fi
    fi

  4. #4
    Join Date
    Nov 2015
    Posts
    2

    Default

    Here is an example

    sh /app/pentaho/design-tools/data-integration/kitchen.sh -file=/home/dmi/gitsink/dmi_dataintegration/pdi/capital_group/CG_Redshift_to_FTP.kjb -param:saveDir='/home/dmi/'

  5. #5
    Join Date
    Dec 2009
    Posts
    332

    Default

    dpiestrak - Since you are listing out the path name to the kettle job does it make any difference whether or not you include the "-norep" argument?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.