title: Spark application finished callback
body: <p>I have a bash script that every night starts my standalone EC2 Spark cluster and executes an application. I would like to be noticed when the application has finished so I can stop the cluster. </p>
  
  <p>I was wondering if there is some sort of callbacks based on spark application status.</p>
  
  <p>I'm pretty new to spark so another hint to solve this will be appreciated.</p>
  
  <p>Thanks. </p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>With the json provided by <code>http://&lt;master-host&gt;:8080/metrics/master/json</code> or <code>http://&lt;master-host&gt;:8080/metrics/applications/json</code> I can get the status of the application (WAITING,RUNNING,FINISHED) but I can't get the status of the driver that will tell you if the execution FAILED. I'm sure that there must be an specific configuration for the metrics to show this, but I couldn't find it. </p>
  
  <p>In order to get this kind of status I scrapped the web UI provided in <code>http://&lt;master-host&gt;:8080</code> to find the driver executing my application and get its status.</p>
  
  <p><img src="https://i.stack.imgur.com/4Ex10.png" alt="enter image description here"></p>