Skip to content

Instantly share code, notes, and snippets.

@iconara
Last active October 5, 2015 12:46
Show Gist options
  • Save iconara/c97779672d808b0f6f6b to your computer and use it in GitHub Desktop.
Save iconara/c97779672d808b0f6f6b to your computer and use it in GitHub Desktop.
Find the error and file that caused an EMR job to shut down
#!/bin/bash
# Tested with EMR AMI 3.9.0, but most likely does not work except
# in fortuitous constellations of errors
failed_task_id=$(zgrep -F 'Task failed' steps/*/syslog.* | head -n 1 | perl -p -e 's/^.*(task_\S+).*$/$1/')
failed_task_log=$(zgrep -l -R -F $failed_task_id task-attempts | tail -n 1)
failed_attempt_id=$(zgrep -F FATAL $failed_task_log | head -n 1 | perl -p -e 's/^.*(attempt_\S+).*$/$1/')
failed_attempt_log=$(zgrep -l -R -F $failed_attempt_id task-attempts | tail -n 1)
zgrep -F 'Processing split' $failed_attempt_log
zgrep -A 10 -F 'Exception running child' $failed_attempt_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment