Requirement
Execute a Java file every 2 minutes
You alreay have a Java file which resides in a directory called " /home/jjj/bridge/heartbeat/" and which you can execute from the command line with:
java -classpath /home/jjj/bridge/heartbeat/ojdbc6.jar:. hb_bridge_util_mem_usage
Solution
Create a shell script
#!/bin/bash
java -classpath /home/jjj/bridge/heartbeat/ojdbc6.jar:. hb_bridge_util_mem_usage
Create a cronjob
crontab -e
*/2 * * * * (cd /home/jjj/bridge/heartbeat/; ./hb_bridge_util_mem_usage.sh)
Debugging
When I had issues with the syntax, the cron job would send an email
Open the message with
read the latest email with "1" (i.e message 1)
I had a lot of email - as the job was running every 2 minutes and failing...
delete *
Quit with
q
Acknowledgement
https://unix.stackexchange.com/questions/98914/how-to-use-crontab-for-a-java-file-in-linux
https://apple.stackexchange.com/questions/28745/how-do-i-delete-all-terminal-mail
Comments
Post a Comment