1. Use kitchen.sh to write a shell script as a pdi task (the script name is: /opt/webex/spark_metrics.job)
#!/bin/sh export JAVA_HOME=/usr/java export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JRE_HOME=$JAVA_HOME/jre cd /opt/webex/pentaho_data_integration ./kitchen.sh \ -file $PWD/resources/pdi/spark_metrics/Spark_Metrics_Job.kjb \ -param:"du_etl_hostname=ip" \ -param:"spark_metrics_api=http://ip/du/api/v1.0/checks/redisSparkMetrics" \ >>/opt/webex/pentaho_data_integration/logs/ten_min_`date +%Y%m%d%H%M`.log
important point:
(1) You must add export to the shell to configure the java environment variables, otherwise there will be the problem of spoo.sh command line not found
(2) The output log is placed at the end. You can use the shell's date command format %Y%m%d%H%M to output 201711101026.log
2. Write cronJob
10,30 * * * * /opt/webex/spark_metrics.sh
Delegate: trigger this shell script at 10,30 minutes of every hour
Note: The general format of crontab is:
10,30 * * * * opt/webex/spark_metrics.sh >dev/null 2>&1
The first >dev/null: The normal log stream is output to null, that is, no output
The second 2>&1 : The error log stream is the same as the normal stream output