Ujjwal SIddharth Ujjwal SIddharth - 11 months ago 121
Scala Question

Exiting Spark-shell from the scala script

I am using this command to run scala scripts.

spark-shell -i test.scala

At the end of the execution of the script I still see spark-shell running.

I have used ":q/:quit" in the test.scala script to try and exit but it's not working.

Kindly provide me a solution :)

Answer Source

You need to add exit() at the end of your script to avoid stepping into scala REPL.


print("Hello Worl"); print("Second Line"); print("Bye now"); exit()

Run above spark-shell -i helloworld.scala

Thanks, Charles.