我在我的java程序中使用Quartz Cron触发器.我使用的Cron表达式是0 0***?
现在我想要一个调度程序每小时执行一次.为了测试相同的启动我的jboss服务器,然后我将我的窗口时间重置为5:59:45和6:00:00,调度程序没有激活.
现在,下次我第一次调整时间说5:55:00然后我启动服务器并且调度程序在6:00:00解雇.
服务器或调度程序是否在内部保持时间,当然最初是用系统时序初始化的?
我正在使用Quartz Enterprise Job Scheduler(1.8.3).作业配置来自几个xml文件,我们有一个特殊的作业,可以检测这些xml文件中的更改并重新计划作业.这很有用,但问题是我还需要这个"调度程序工作"来重新安排自己.一旦这个工作重新安排自己,由于某种原因,我看到它被执行了很多次.但我没有看到任何例外.
我已经复制并隔离了这个问题.这将是切入点:
public class App {
public static void main(final String[] args) throws ParseException, SchedulerException {
// get the scheduler from the factory
final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
// start the scheduler
scheduler.start();
// schedule the job to run every 20 seconds
final JobDetail jobDetail = new JobDetail("jobname", "groupname", TestJob.class);
final Trigger trigger = new CronTrigger("triggername", "groupname", "*/20 * * * * ?");
// set the scheduler in the job data map, so the job can re-configure …Run Code Online (Sandbox Code Playgroud) 我有一个有多个工作的调度程序.我希望能够显示调度程序中的所有活动作业,我的意思是我想在每个作业被触发时显示.这是我的代码:
sched.start();
JobDetail job = newJob(Jobs.class)
.withIdentity(job_name_, "default")
.usingJobData("job_type", job_type_)
.build();
Trigger trigger = newTrigger()
.withIdentity(job_name_, "default")
.startNow()
.withSchedule(cronSchedule(date_time_))
.build();
sched.scheduleJob(job, trigger);
Run Code Online (Sandbox Code Playgroud)
如何才能做到这一点?如何从作业的触发器中获取cron表达式?还有一种方法可以将cron表达式视为日期或表达本身更详细的东西吗?
任何帮助将被批准,
提前致谢.
我正在测试Quartz来安排工作.但是,该作业包含3个不可序列化的参数.
我在下面创建了一个示例应用程序,指示我如何实现该功能.有谁知道如何使用Quartz将自定义对象用作参数?
下面是调度工作的触发器,我已经评论了给我问题的区域.
public class Trigger {
public void run() throws Exception {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
Date startTime = DateBuilder.nextGivenSecondDate(null, 15);
JobDetail job = newJob(SimpleJob.class)
.withIdentity("job6", "group1")
.build();
SimpleTrigger trigger = newTrigger()
.withIdentity("trigger6", "group1")
.startAt(startTime)
.withSchedule(simpleSchedule()
.withIntervalInSeconds(60)
.repeatForever())
.build();
Date ft = sched.scheduleJob(job, trigger);
TestObject testObject = new TestObject();
// This is the part giving trouble!
job.getJobDataMap().put(SimpleJob.test,testObject);
sched.start();
}
Run Code Online (Sandbox Code Playgroud)
}
这是我要安排的工作.
public class SimpleJob implements Job {
public static final TestObject test = null; …Run Code Online (Sandbox Code Playgroud) 我想整天运行我的Quartz作业4次,我正在使用cron作业来触发我的工作,并在xml中提供了价值.请让我知道Quartz Expression,以便我可以整天触发我的工作4次.
我们使用石英调度程序进行调度,我需要每2.5小时执行一次作业.请为此构建一个cron表达式.提前致谢.
我有一个Web应用程序,我使用spring应用程序上下文来注入我的bean,在我的应用程序中使用@Autowired注释我有一个服务,有一个生成报告的方法,这个服务是这样的:
public ReportingService extends CommonService {
//this method is called from a controller to generate a report right now
//after filling the parameters of the report i.e. businessday
public generateReport(Request request) {.....}
public generateScheduledReport() {
//read configured parameters from database and fill request
Request rr = ...;
generateReport(request);
}
Run Code Online (Sandbox Code Playgroud)
对于计划的报告,我已经定义了一个扩展QuartzJobBea`的作业,并使用我的ReportingService的一个字段来调用它的generateScheduledReport,如下所示:
public class ScheduledReportJob extends QuartzJobBean {
@Autowired
@Qualifier("reportScheduler")
CommonService reportScheduler;
//getters and setters
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
reportScheduler.generateScheduledReport();
Run Code Online (Sandbox Code Playgroud)
在我的applicationContext中,我按如下方式设置了quartz和spring bean:
<bean id"reportScheduler" class="com.monim.ReportingService"/>
<bean name="schedulingjob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"> …Run Code Online (Sandbox Code Playgroud) 我正在使用Graz的Quartz插件来逐步进行同步作业,但是我无法使用该0 * * * * *定义并抛出一些异常:
加载插件管理器时出错:无法找到类grails.plugins.quartz.DefaultGrailsJobClass的Class参数的构造函数(注意:已经过滤了堆栈跟踪.使用--verbose查看整个跟踪.)
引起:java.lang.IllegalArgumentException:作业类中的Cron表达式'0*****'cl.ionix.softoken.jobs.SendRefreshStatusByMinuteJob不是有效的cron表达式
什么是每分钟执行正确的cron表达式?
我正在例外
org.springframework.beans.factory.BeanCreationException:在类路径资源中创建名称为“ quartzScheduler”的bean时出错
谁能帮我解决问题。
我正在使用以下依赖
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
`enter code here`<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的代码如下
@Configuration
@ComponentScan(
basePackages = {"com.test"},
useDefaultFilters = false,
includeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Service.class),
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Component.class)
})
public class QuartzConfig {
// this data source points to the database that contains Quartz tables
@Autowired
private DataSource dataSource;
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
private ApplicationContext applicationContext;
@Bean
public SchedulerFactoryBean quartzScheduler() {
SchedulerFactoryBean quartzScheduler = new SchedulerFactoryBean(); …Run Code Online (Sandbox Code Playgroud) 我在Asp.Net C#中使用Quartz.Net来安排我的任务.我想写一个文件,当我尝试没有MapPath它按预期写入文件(Hello world).
这是我写的代码.我曾尝试HostingEnvironment.MapPath和Server.MapPath.它只是在没有任何内容的情况下编写文件.
public void Execute(IJobExecutionContext context)
{
StreamWriter file = new StreamWriter("destination_actualPath\\hello1.txt", true);
file.WriteLine("Hello world " + Server.MapPath("../Data"));
file.Close();
}
Run Code Online (Sandbox Code Playgroud)
是的,此文件夹Data确实存在于我的项目目录中.这个函数在IJob类中.如果我写一个新方法(除了执行)它正在写入文件(hello world和path),如果它在这个Execute方法中,它就不会写任何内容到文件中.
quartz-scheduler ×10
java ×6
cron ×2
crontrigger ×2
asp.net ×1
crontab ×1
grails ×1
jobs ×1
quartz.net ×1
scheduler ×1
spring ×1