Returning to Vilna, he married the daughter of the wealthy Shimon Wolf, a great-grandson of Moses Isserles, and shortly after was appointed to the Beit Din as one of the assistants of Moses ben Isaac Judah Lima, author of "Chelkat Mechokek". In 1655, during fighting between Polish forces and the invading Swedish army in the Northern War, Shabbatai HaKohen fled Vilna with the entire Jewish community. After a short stay at Lublin he went to Prague and later to Strážnice in Moravia, from where he was called to the rabbinate of Holešov, where he remained until his death in 1662. While in Holešov, he gained the friendship of Magister Valentino Wiedreich of Leipzig. The Shakh′s grave in the Jewish cemetery of Holešov still exists and is visited by people from all over the world. A portion of his descendants have taken the last name Hakohen Rubin, although their reasons for doing so are unknown.