0

I need a shell script that would run two .sh files which are in the directory: /opt/tomcat-latest/bin

#!/bin/sh

cd /opt/tomcat-latest/bin
./shutdown.sh
./startup.sh

Would this code achieve my goal? If so how do I make it on a cron job that runs every 2 hours? I have a Linux Centos VPS and DirectAdmin admin panel.

1 Answers1

0

I think the easiest solution would be to run directly the commands with its full path from cron, instead of using a sh script.

Something like this in the crontab would work :

* */2 * * * /opt/tomcat-latest/bin/shutdown.sh && /opt/tomcat-latest/bin/startup.sh

That would run every 2 hours you can edit crontab with crontab -e and check the crontab syntax here : https://fr.wikipedia.org/wiki/Crontab

Francois
  • 515
  • 4
  • 14
  • `[root@server bin]# crontab -u root -l` Gave: `* */2 * * * /opt/tomcat-latest/bin/shutdown.sh && /opt/tomcat-latest/bin/startup.sh` So it should all be good now right? –  Oct 10 '15 at 10:09