- Create a script file tomcat_service.sh and add the following lines
#Use this script for tomcat running as a service
#!/bin/bash
#Stop Tomcat
systemctl stop tomcat
#Wati for 60 seconds
sleep 60
#Start Tomcat
systemctl start tomcat
2. Make the script executable
chmod +x tomcat_service.sh
3. Automate script execution
3.1 Open crontab for editing
crontab -e
3.2 Add a line to execute the script at specific time
0 0 * * * /path/to/tomcat_service.sh
Now, your Tomcat Service should automatically stop and start according to the schedule you have set in the cron job. Adjust the timing and frequency in the cronjob as needed.