#!/bin/sh ### BEGIN INIT INFO # Provides: java service # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start up the java service daemon. # Description: Start up the java service daemon. ### END INIT INFO BASE_DIR="/home/yangxianchao/pq" PID=$(ps -ef | grep com/st/pq/SendComments | awk '{if($3==1){print $2}}') cd $BASE_DIR start(){ if [ "$PID" == "" ] then for i in *.jar do CLASS_PATH=$CLASS_PATH:$i done java -cp $CLASS_PATH com/st/pq/SendComments > /dev/null 2>&1 & sleep 1 echo "Start." else echo "It's running." fi } stop(){ if [ "$PID" == "" ] then echo "It's not running." else kill $PID sleep 1 echo "Stop." fi } status(){ if [ "$PID" == "" ] then echo "stop" else echo "running" fi } case $1 in start) start ;; stop) stop ;; status) status ;; *) echo "start|stop|status" ;; esac
Month: 7月 2013
ie678 浏览器与 chrome、firefox 在处理 new Date() 时的区别
var dateStr = "2013-07-10"; var dateObj = new Date( /msie/i.test(navigator.userAgent) ? dateStr.replace( /\-/, "/" ) : dateStr );
求两个日期区间段的交集
$t1 = strtotime('2013-07-01 00:00:00'); $t2 = strtotime('2013-07-10 23:59:59'); $s = strtotime('2013-07-05 00:00:00'); $e = strtotime('2013-07-15 23:59:59'); $xs = date( 'Y-m-d H:i:s', $t1 > $s ? $t1 : $s ); $xe = date( 'Y-m-d H:i:s', $t2 < $e ? $t2 : $e ); if( ($s >= $t1 && $s < = $t2) || ($t1 >= $s && $t1 < = $e) ){ echo $xs, ' ', $xe, "\r\n"; } $xs = $t1 > $s ? $t1 : $s ; $xe = $t2 < $e ? $t2 : $e ; if($xs <= $xe){ echo date('Y-m-d H:i:s', $xs), ' ', date('Y-m-d H:i:s', $xe), "\r\n"; }
JAVA产生两个数值区间的随机数
public static int getRandom(int min, int max) { int r = new Random().nextInt(max - min); return r + min; }