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
297 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,240 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,100 points
58 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,490 points
50 views
0 votes
1 answer
0 votes
1 answer
+13 votes
2 answers
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,240 points
355 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 26 in DevOps & Agile by hal
1,024 views