Run a job at a specific time

How can setup when a job will be run?
I want to setup a job to be run each nigth. I can setup that the job is run each day (86400 seconds) but it’s run at time It was created but I want to choose the hour it is run.

Hi,

The easiest way is to create a API request and cronjob it:

Hi

first of all Icinga is not a tool like a typical job scheduling software or a task scheduler (like cron job at Linux or task scheduler on Windows). So the next check is calculated from the last check time with the check_interval and maybe also a retry interval if the host is down. What I mean is if you have for example a check interval from 5 min and retry interval with 3 min with max check attempts from 5. If the check is one or two time down, after some time the check is not running at same time at all.
This also happens if you stop the icinga2 daemon for a while and start again.

So with this information what you can do?

  • What you can do is to create a individual time period for the check. That means your check run for example only between e.g. 0:00 and 0:15.

  • You stop once the icinga2 daemon at night and restart it again. So the algorithm calculate a new rythm for the check. But as I wrote above also consider the retry interval and the max check attempt if the host is down for some time.

  • You can also do a mix with a task scheduler and the possability of passive check. So after running a script with e.g. crond the last step will be the check result. But the disadvantage is you’ll never see if the script has a problem. But the passiv check has a configuration option where you define that you expect a check result during a specific time period.

I think I don’t explaind myself fine. The job I want to shedule is not related with checks, it is the import of data from netbox. I want to shedule a job to import data from netbox all nigth

Sorry but I don’t see how I can call to “Import Source” or “Sync Rule” from API

Ok, for import data in the the director you need the “automation” menue. You create fowolling:

  1. the import source:
  2. the next step are the sync rules
  3. the last step are the jobs for import, syncing and deploy.
    image



    For this step you need also a timeperiod when this should be happen.

A short doc you’ll find here: https://icinga.com/docs/director/latest/doc/70-Import-and-Sync/
Here is the doc for the jobs: https://icinga.com/docs/director/latest/doc/79-Jobs/

and if you want to do this with the CLI look at here: https://icinga.com/docs/director/latest/doc/60-CLI

I don’t understand why yours screenshoot are not the same that I has.
There are fields like time period and grace period that I don’t have

We are using Director 1.7.2. Which version you are using?