Scheduled jobs with cron

Hello dear community,

I need your help  !

How can i scheduled one job every 14 days with cron  on uCMDB.

If i do that :

0 0 8 */14 * ?

it means ==>  "At 08:00:00am, every 14 days starting on the 1st, every month"

But i don't want his part "on the 1st". I just want every 14 days at 08am

Is there any possibilities to do that ?

Thanks by advance.

 

 

 
  • Because cron is "stateless", it cannot accurately express "frequencies", only "patterns" which it (apparently) continuously matches against the current time.

    Rephrasing your question makes this more obvious: "is it possible to run a cronjob at 08:00am every night except skip nights when it had run within 13 nights?" When cron is comparing the current time to job request time patterns, there's no way cron can know if it ran your job in the past.

    Therefore no, it is not possible to do exactly what you want with cron. You can use Interval scheduling for that. 

     

    Regards,

    Petko

  • ok thx for the reply

     

    The problem is when my scheduled inventory is call by a triggered query, it schift my planification every time. So my inventory never start like i want. 

  • I am not exactly sure what is the problem. When the trigger query finds a new CI, it executes the job immediately without shifting the whole schedule. 

  • it is unfortunatly i don't know why we have this problem.

  • Can you share screenshots? I have used the job for ages and I have never seen such issue.

     

  • Which one ? scheduling parameters  ?

  • Inventory Discovery by Scanner is not like the agent-less jobs. Inventory Discovery is asynchronous and you must think and plan for this in your schedule. I use Inventory Discovery in my production environment and my overall plan is that I want to collect 1 scan from from every computer in every 7 day period. For the general use case I don't care on what day I receive the scan file but only that I have a new scan in every 7 day period.

    Now I have 3 different scan configuration for my specific use cases.

    1. Laptop / Desktop or Client computers
    2. Servers / Virtual machines in Datacenter
    3. Important servers used for software development (specific collection window)

    In the first use case I'm targeting laptop / desktop of business users. I plan to start scan cycle on Monday and continue attempts all week until I get a completed scan from each connected device. I have configured the schedule for 1 minute past midnight on Monday with time zone of GMT (not probe time zone). Invoke on new trigger CIs is allowed.
    Client_Schedule.png

    In the second use case I'm targeting servers and virtual machines and I make assumption that these will be mostly idle on weekend. I start the scan cycle on Friday at 6 PM using probe time zone because the probes are in the data centers. I have configured a random delay in the scan configuration of up to 1 day (86400 seconds). The delay in the start of the scan is to help mitigate if all the scans started at once on virtual machines and overloaded the ESX servers and back end storage. So effectively I have scan cycle start time between Friday and Saturday and continues all week until I get a completed scan. Invoke on new trigger CIs is allowed.
    Datacenter_Schedule.png

    In the third use case I have a specific requirement to impact these servers as little as possible. I have a specific scan collection window of Friday at 11 PM and must stop by 7 AM Monday. There are about 1000 servers in this use case on multiple class C IP ranges. I have configured 1 probe with all these IP ranges for this special case. Therefore I have probe limited for this job to that probe only. I have configured a discovery schedule with these specific days and times so that when it gets to Monday at 7 AM all inventory discovery is blocked until Friday at 11 PM. I have configured the job schedule to start at 11 PM on Friday using the probe time zone. I have configured a hardware only scan with no delay. These servers are used to build and compile our software product and I want scan executable to be in the process list for as short a time as possible. Historically I have collected all scans from these systems within the first hour. I have only needed the extra days if a scheduled computer was offline at the start of the scan cycle. Invoke on new trigger CIs is not allowed. Any new servers spun up in these IP ranges will have to wait until the next scan cycle to be discovered. If added outside the discovery window they would be blocked anyway but I prefer not to have the job blocked spam in the discovery logs.
    Specific_Schedule.png

    The job Discovery Progress table is useless since it only shows the progress of when I started the job. So only the first week the jobs were started after that it shows 100% progress. To understand the effectiveness of my inventory discovery by scanner collection I look at the processed folder on each of the probes. I sort by last modified date and look at how many are not for the current 7 day period. The older scan file will be there for 1 of 2 reasons:

    • Scan file name changed. Either renamed or different MAC address or other reason that scan file name changed.
    • Scan was not completed. Computer was offline, scanner had an error or computer was unreachable.

    I hope that my examples have helped you to think about how you might configure your inventory discovery with cron.

  • Verified Answer

    Thanks so much ! it definitely help !

    Our inventory are very loud...we are thinking about change the way we process that.