Skip to content

Instantly share code, notes, and snippets.

@delijati
Last active February 14, 2019 20:20
Show Gist options
  • Select an option

  • Save delijati/7ba8b378b5c629eb0dbdc126ef197f4e to your computer and use it in GitHub Desktop.

Select an option

Save delijati/7ba8b378b5c629eb0dbdc126ef197f4e to your computer and use it in GitHub Desktop.
#!/bin/bash
set -x
LOCAL_DIR=/home/hadoop/yarn_logs
mkdir $LOCAL_DIR
for row in $( yarn application -appStates ALL -list | awk '/application_/{print $1 "," $2}' )
do
fields=($(echo $row | tr "," "\n"))
yarn logs -applicationId ${fields[0]} > $LOCAL_DIR/yarn_${fields[0]}_${fields[1]}.log
done
if [ -z "$(ls -A $LOCAL_DIR)" ]; then
echo "($LOCAL_DIR) is empty"
else
aws s3 cp $LOCAL_DIR/*.log s3://out/
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment