...
Info |
---|
If you want to run a cronjob inside the Checkmk site, please follow this short How-To. |
Status |
---|
colour | Green |
---|
title | LAST TESTED ON CHECKMK 2.3.0P1 |
---|
|
Panel |
---|
borderColor | black |
---|
bgColor | #f8f8f8 |
---|
title | Table of Contents |
---|
|
|
List all the cronjobs enabled on your checkmk site:
With crontab -l executed as site user, you will get an overview of all installed crontabs the configured cronjobs inside the Checkmk site.
These are all the cronjobs available by default on a checkmk site:
Code Block |
---|
|
OMD[mysitecheckmk]:~/etc/check_mk/multisite.d/wato$~$ crontab -l
#
# Do not edit this file. It will be recreated each time OMD
# is started or reloaded.
#
# execute 'omd reload crontab'
# to rebuild this file out of /omd/sites/mysitecheckmk/etc/cron.d/*
#
# --ENVIRONMENT------------------------------------------------
SHELL=/bin/bash
BASH_ENV=/omd/sites/mysitecheckmk/.profile
OMD_ROOT=/omd/sites/mysitecheckmk
OMD_SITE=mysitecheckmk
PATH=/omd/sites/mysitecheckmk/local/bin:/omd/sites/mysitecheckmk/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin
MAILTO=""
# ------------------------------------------------------------
# /omd/sites/mysitecheckmk/etc/cron.d/cmk_bulk_notify
# Needed for bulk notifcations.
# Only execute cmk --notify when the microcore is currently not enabled.
* * * * * [ ! -e /omd/sites/checkmk/etc/check_mk/conf.d/microcore.mk -a -d /omd/sites/checkmk/var/check_mk/notify/bulk ] && cmk --notify send-bulks
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_cleanup_pdf_tmp_files
# Once a day, at 00:15, search for PDF tmp files older than 1 day and delete them
15 0 * * * [ -d "$OMD_ROOT/tmp/check_mk/pdf" ] && find $OMD_ROOT/tmp/check_mk/pdf -maxdepth 1 -name tmp\* -mtime 1 -delete
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_cleanup_piggyback
# Once a day, at 00:10, cleanup outdated piggyback files
10 0 * * * cmk --cleanup-piggyback
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_dns_cache
# Once a day, at 00:05, update IP address cache of all Check_MK hosts
5 0 * * * cmk --update-dns-cache
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_inventory
# Every 5 minutes autoinventory hosts marked by inventory check
*/5 * * * * cmk --inventorize-marked-hosts
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_license_email_notification
# Run every day at 00:00
0 0 * * * /omd/sites/checkmk/bin/cmk-license-email-notification
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_multisite
# Run Multisite regular jobs, e.g. scheduled reports
* * * * * .. |
Step-by-step guide
Option
...
$OMD_ROOT/etc/omd/site.conf ; curl http://localhost:$CONFIG_APACHE_TCP_PORT/checkmk/check_mk/run_cron.py >/dev/null 2>&1
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/cmk_update_license_usage
# Run every 30 minutes between 8am and 5pm
# Note: in update_license_usage() the next (random) time point is set between 8am and 4pm
*/30 8-17 * * * /omd/sites/checkmk/bin/cmk-update-license-usage
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/diskspace
#
# Run every hour, 5 minutes after full hour
#
5 * * * * diskspace >> $OMD_ROOT/var/log/diskspace.log 2>&1
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/logrotate
#
# Daily Logrotate
#
0 0 * * * $OMD_ROOT/bin/logrotate -s $OMD_ROOT/tmp/run/logrotate.state $OMD_ROOT/etc/logrotate.conf >/dev/null 2>&1
# ------------------------------------------------------------
# /omd/sites/checkmk/etc/cron.d/php-sessions
# Once a day, at 00:10, search for PHP sessions that are older than 1 day and delete them
10 0 * * * find $OMD_ROOT/tmp/php/session -name sess_\* -mtime +1 -delete
# ------------------------------------------------------------ |
Configure your new cronjob:
By default, all the cron jobs associated with the checkmk site are stored inside the ~/etc/cron.d .
To create a new cron job, you need to create a new file, as site user, inside the ~/etc/cron.d directory.
Example: ~/etc/cron.d/myjob:
Code Block |
---|
|
# My cronjob
*/5 * * * * $OMD_ROOT/local/myjob --params >/dev/null 2>&1 |
...
Replace the $OMD_ROOT/local/myjob --params >/dev/null 2>&1 with the path of your script and the needed parameters.
To enable the newly created cronjob, you need to reload crontab, as site user:
Code Block |
---|
|
OMD[checkmk]:~$ omd reload crontab |
...
Removing Crontab...OK
Initializing Crontab...OK |
Check if the new cronjob was enabled (troubleshooting):
To check if the newly created cronjob is enabled, do this:
Code Block |
---|
|
OMD[checkmk]:~$ crontab -l | grep myjob
#myjob
*/5 * * * * $OMD_ROOT/local/myjob --params >/dev/null 2>&1 |
If you need help configuring the execution time for your cronjob, you can use the Crontab.guru tool.
Related articles
Filter by label (Content by label) |
---|
showLabels | false |
---|
max | 5 |
---|
spaces | KB |
---|
showSpace | false |
---|
sort | modified |
---|
reverse | true |
---|
type | page |
---|
cql | label in ( "site" , "cronjob" , "howto" ) and type = "page" and space = "KB" |
---|
labels | cronjob site |
---|
|
...