Crontab across server

HI All,

I have 2 linux machine (machine A and machine B)

please advise for create crontab script for below condition:

  1. I need create crontab in machine "A"
  2. on machine "A" have Tomcat process, if Tomcat process is off on machine "A" than running command to start Tomcat on machine "B"

how to enable the condition using crontab?

please advise

Thanks

You could try this as a cronjob on machine A, the below checks tomcat is running each hour through the business day (8am - 5pm) and if it's not uses ssh to start it on machineB:

0 9-17 * * * if ! service tomcat status > /dev/null; then ssh machineB service tomcat start; fi

Of course this requires password-less ssh from machineA to machineB to be setup. There should be plenty of threads that discuss how it's done on this forum.

hi Chubler,

thank u for response

can u give me example detailly?
my bash skills are rusty, please give me an example