@priyal patel
If it is ambari managed cluster then you shoudl make the changes from Ambari UI
Ambari UI --> Spark --> Configs --> Advanced-- "Advanced spark2-env"
Ambari UI --> Spark --> Configs --> Advanced-- "Advanced spark-env"
Then after saving the changes ambari will show restart required icon for the host components that requires restart and during restart of spark components it will push the spark-env. (spark2-env) related changes to the respective hsots.