1. 首先写好你的java quartz job, 然后用Eclipse把它导出成runnable jar
2. 编写shell脚本
#!/bin/sh # chkconfig: 23456 80 10 # description: check pnr export SERVER=/usr/job/ cd $SERVER case "$1" in start) nohup java -server -jar ZeusService.jar zeus.quartz.air.XePnrTrigger -Xms128m -Xmx1024m & echo $! > $SERVER/server.pid ;; stop) kill `cat $SERVER/server.pid` rm -rf $SERVER/server.pid ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: run.sh {start|stop|restart}" ;; esac exit 0
3. 发布服务
1) 将SH脚本文件ZeusService 放至 etc/init.d
2) 将ZeusService.jar 放至 usr/job 目录下
3) 执行语句
chkconfig --add ZeusService //添加注册
cd /etc/init.d //跳转目录
dos2unix ZeusService //文件格式转换(可选)
chmod 777 ZeusService //授权
service ZeusService start //启动服务
ps aux | grep ZeusService //检查服务是否启动
时间: 2024-10-12 14:36:19