issue with running .sh file

Four Stars

issue with running .sh file

Hi,

 

I have a job that runs .sh file but talend shows the complete status though the job still runs. Any idea how to control this so that talend gives the complete status only after .sh execution or all the command completes on .sh file. 

Moderator

Re: issue with running .sh file

Hello,

Are your job running well when you execute .sh file? What does the complete status look like? Could you please give us some trouble screenshots?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: issue with running .sh file

Hi, 

 

I am using tssh component where it calls .sh file from unix. After i run this job in talend. I see connected, completed and disconnected message on talend console and then I go check on the log that sh file generates, i see these files generated even though status on the talend shows completed. 

 

Below is part of the shell script. This script basically generates log files and has operations like creating tables, inserting data to table and so on. And all these operations complete successfully after talend complete message. I want talend to show me complete after finishing all these operations. 

 

./file.properties

targettable="Account"
echo "Start execution of ${targettable} table execution ${scripts_dir}"
echo "logged at ${log_dir}"
echo "File Datetime: ${FILE_DATETIME}"
echo "queue name: ${queue_name}"
echo "............"
echo "${scripts_dir}${targettable}_TXT_to_HIST.hql"
echo "............"

# creating log files for hive file processing
log_file_name=${log_dir}${targettable}data_load_${FILE_DATETIME}.log

touch $log_file_name
exec >> $log_file_name;
exec 2>> $log_file_name;

echo "successfully created logfile...."
echo $log_file_name

echo "Script executed by `whoami` at `date "+%Y-%m-%d %H:%M:%S"`"
echo "Project directory: $dir_project"

job_message="Populable ${targettable} table"
user=`whoami`
incrementaltable=${targettable}_stg
job_id=1

...contd

Four Stars

Re: issue with running .sh file

Any update to this please. If any questions please let me know. 

Four Stars

Re: issue with running .sh file

hello,
Right click on your .sh file and select Properties:

In the Permissions tab, check Allow executing file as program:

Close the Properties window and double-click the file. A dialog will pop up giving you the option to run the script in a terminal:
regards
jenifer
Four Stars

Re: issue with running .sh file

Hi, this sh file is in unix machine. And I am connecting to execute from Talend. 

Four Stars

Re: issue with running .sh file

Hello,

 

 

Add wait in shell script

 

Thanks

Five Stars

Re: issue with running .sh file

Hello,

 

Suppose cmd is having your script(.sh) then assuming it takes time more than 30 sec (time taking task) then
refer below Script.
Hope it helps!!

 

cmd="run.sh"
status="Running"
while [ "$status" != "Completed"]
do
result=`ps aux | grep -i "$cmd" | grep -v "grep" | wc -l`
if [ $result -lt 1 ]
then
echo "script $cmd completed sucessfully ! "
status="Completed"
fi
done
echo "Completed the Task"

 

--
Don't forget to give kudos when a reply is helpful

 

Thanks,

---
Don't forget to give kudos when a reply is helpful.
Thanks