求一个以月为单位的定时任务(比如每月的1号执行一次任务),非web应用,所以不能用spring 的quatz。
部分代码
private static ScheduledExecutorService service = Executors.newScheduledThreadPool(3);
service.scheduleWithFixedDelay(
new AdminReqTask(), 1, periodtime, TimeUnit.SECONDS);
public class AdminReqTask implements Runnable {
.......
.......
}
代码中的periodtime,不知道怎么办(没有TimeUnit.Month),因为一个月的时间不固定。求大神帮忙!先谢了
使用crontab或者直接用quatz就行
这有个说明http://lanhy2000.blog.163.com/blog/static/43678608201142224028308/
大神,我这个不是web程序,不能用quatz啊
@chaser: quatz不需要一定在web程序中用,例子参考 http://blog.csdn.net/szwangdf/article/details/6158646