shell script to restart a tomcat server if down

0 votes
I want a shell script to run as a cron job every half hour to check if server is running or not, if not then turn it back on.
Apr 29, 2018 in DevOps & Agile by Atul
• 10,240 points
4,804 views

1 answer to this question.

0 votes

Try using systemd isntead of a cron job. Create one file for the service and the one other for timer.

example:

/etc/systemd/system/example.service

[Unit]
Description=example job

[Service]
Type=oneshot
ExecStart=/bin/bash /tmp/1.sh

/etc/systemd/system/example.timer

[Unit]
Description=example

[Timer]
OnUnitActiveSec=500s
OnBootSec=500s

[Install]
WantedBy=timers.target

reload the systemd using
systemctl daemon-reload
and use the systemctl command to start and enable the
systemctl start test.timer

systemctl enable test.timer

Hope this helps

answered Apr 29, 2018 by ajs3033
• 7,300 points

Related Questions In DevOps & Agile

+1 vote
2 answers

How do I run Apache server from Docker without mapping to a location?

If you're seeing a 500 error, that's ...READ MORE

answered Oct 18, 2018 in DevOps & Agile by lina
• 8,220 points
2,193 views
+13 votes
2 answers
0 votes
1 answer

How to edit file after I shell to a docker container?

Since docker images are trimmed to bare minimum ...READ MORE

answered Sep 11, 2018 in DevOps & Agile by Damon Salvatore
• 5,980 points
3,788 views
0 votes
1 answer

Docker for Windows error - Connecting a SQL Server database to a Docker container

The latest express sqlserver images with setting ...READ MORE

answered Dec 4, 2018 in DevOps & Agile by Tyrion anex
• 8,700 points
1,416 views
+1 vote
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 views
0 votes
1 answer

How to set up a VM with KVM/qemu without VitualBox using Vagrant

Start the vagrant box using: vagrant up --provider=kvm But ...READ MORE

answered Apr 11, 2018 in DevOps & Agile by ajs3033
• 7,300 points
2,401 views
0 votes
2 answers

Unable to use jenkins to run oracle script on remote DB

add ORACLE_HOME  in jenkins global variable. READ MORE

answered Mar 27, 2019 in DevOps & Agile by hal
6,032 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP