Question:
How can a job, which is only to run once, be started immediately and not be restarted the next time JobScheduler is restarted?
Answer:
The following script will start a job immediately and ensure that it will not be restarted:
<?xml version="1.0" encoding="ISO-8859-1"?> <job title="run once job example" stop_on_error="no" order="no"> <script language="shell"> <![CDATA[ echo run once ]]> </script> <monitor name="DeleteObjectFileAfterExecution" ordering="99"> <script language="javax.script:rhino"> <![CDATA[ function spooler_task_after() { spooler_job.remove(); } ]]> </script> </monitor> <run_time once="yes"/> </job>
The key here is an "undocumented" JobScheduler feature: once="yes"
.
This starts the job immediately, even once JobScheduler has started.
The job is deleted by the post-processor (function spooler_task_after()
) in order to ensure that it will not be restarted the next time JobScheduler itself is restarted.
The post-processor can be omitted if it is not necessary to delete the job.
Insert the code for script that is to be executed in place of "echo run once
".
This solution means that it is no necessary to use a timestamp as a workaround.