Unable to stop and start tomcat server properly using batch file


Unable to stop and start tomcat server properly using batch file



Hi I have a problem with the below commands.


REM : Start server
C:
cd C:Apache Software Foundationapache-tomcat-7.0.22bin
CALL shutdown.bat
cd C:Apache Software Foundationapache-tomcat-7.0.22webapps
RMDIR ProjectWAR /S /Q
DEL ProjectWar.war
cd C:Apache Software Foundationapache-tomcat-7.0.22bin
catalina jpda start



I am trying to shutdown the tomcat server, then delete the project folder and war file and then again start the tomcat server.



But if I run the above code, server is getting shutdown, then only war file is getting deleted (not the projectWar folder) and nothing else. Please help me.





Do you see any errors when the file runs the RMDIR ProjectWAR /S /Q ?
– theglossy1
Feb 11 '15 at 16:12


RMDIR ProjectWAR /S /Q





Maybe there are some files locked under your project folder?
– JosefZ
Feb 11 '15 at 20:39





@JosefZ Firstly, can you please tell me whether the above code piece has any errors? Thanks.
– Ramson
Feb 11 '15 at 21:08





I can't see any errors in your code provided, it looks well. However, there is a hidden shutdown.bat content... I'd add pause at the end and preset echo ON in both scripts. Follow @theglossy1 and make public all error messages...
– JosefZ
Feb 11 '15 at 21:33


shutdown.bat


pause


echo ON




2 Answers
2



When you call the shutdown command, the next commands don't wait for the server to shut down. The folder doesn't get deleted because it is still being used by the server (which is in the process of shutting down but not actually shutting down). So when it's done, the server is shutdown and the war is deleted (because nothing is using the war), but the folder is still there because when the delete command was called it was in use.


taskkill /f /t /im java.exe
timeout /t 30
pushd "tomcatHomebin"
call startup.bat





Please, do not use the comments space to add code - it is literally unreadable! Edit & update your post instead!
– desertnaut
Jun 29 at 9:37






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV