小白写linux环境下的定时监测

本人做了多年的java,但是对于linux环境基本上还是小白一个,之前做了一个java的定时处理,但是好像会过了10来天就会挂掉。

但是java也没有日志。所以也不清楚怎么去调查。所以想写一个定时监测程序,如果监测到java程序挂掉的话就再次启动java程序。

于是在linux的crontab中加了一段定时监测代码。

文件etc/crontab中加入了以下代码:

 

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/59 * * * * root sh /alidata/runall.sh monitor >>/alidata/log/monitor.log
#

-------------------------------完-------------------------------------

posted @ 2016-05-16 18:34  final0901  阅读(187)  评论(0编辑  收藏  举报