I have a script, it restarts tomcat in 2 minutes,, I would like that
this script was started constantly after server restart, I will be grateful if someone shows how to do it?
#! /bin/bash
sleep 120
systemctl restart tomcat
I have a script, it restarts tomcat in 2 minutes,, I would like that
this script was started constantly after server restart, I will be grateful if someone shows how to do it?
#! /bin/bash
sleep 120
systemctl restart tomcat
2
Answers
Read archwiki about systemd/Timer or maybe original freedesktop documentation about systemd.timer.
Create a file
my_super_tomcat_restarter.timer
in/etc/systemd/system/
:Create a file
my_super_tomcat_restarter.service
in/etc/systemd/system/
with the content:Execute from your terminal as
root
:The timer should fire in 120 seconds and execute
my_super_tomcat_restarter.service
which in turn will restart your tomcat service.either add it in
init.d
orsystemd
based on your Linux distribution of yours. in both cases you have to be root to add your script.