分析和优化crontabs

是否有一个工具来绘制,分析和帮助优化crontab执行?

为了澄清,我正在考虑一个工具,它会生成cron作业执行的时间图,并帮助系统pipe理员巧妙地重新组织它们。

我做的唯一的事情就是将cron作业移动到一个结构化的作业调度程序中,以便绘制依赖关系并获得closures效果窗口的可见性。

某种types的框架为每个cron作业分配一个唯一的ID,并将其与日志文件中的相关联,和/或logging到特定的位置以logging运行时信息(而不是正常的输出日志)。 不过,devise它并不会很简单,但对于小型系统来说,通过查看您的crontabs和日志文件很容易。

不过,我想你不是在谈论小型系统。

听起来像这是你想要的functionhttp://www.phpclasses.org/package/6673-PHP-Parse-crontab-schedule-and-generate-Gantt-charts.html

我不能担保以上,这只是一些networkingsearch的结果。

用于打印按时间sorting的所有系统任务的脚本

#!/bin/bash CRONTAB='/etc/crontab' CRONDIR='/etc/cron.d' tab=$(echo -en "\t") function clean_cron_lines() { while read line ; do echo "${line}" | egrep --invert-match '^($|\s*#|\s*[[:alnum:]_]+=)' | sed --regexp-extended "s/\s+/ /g" | sed --regexp-extended "s/^ //" done; } function lookup_run_parts() { while read line ; do match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+') if [[ -z "${match}" ]] ; then echo "${line}" else cron_fields=$(echo "${line}" | cut -f1-6 -d' ') cron_job_dir=$(echo "${match}" | awk '{print $NF}') if [[ -d "${cron_job_dir}" ]] ; then for cron_job_file in "${cron_job_dir}"/* ; do # */ <not a comment> [[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}" done fi fi done; } temp=$(mktemp) || exit 1 cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}" cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */ <not a comment> while read user ; do crontab -l -u "${user}" 2>/dev/null | clean_cron_lines | sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}" done < <(cut --fields=1 --delimiter=: /etc/passwd) cat "${temp}" | sed --regexp-extended "s/^(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)$/\1\t\2\t\3\t\4\t\5\t\6\t\7/" | sort --numeric-sort --field-separator="${tab}" --key=2 --key=1 | sed "1i\mi\th\td\tm\tw\tuser\tcommand" | column -s"${tab}" -t rm --force "${temp}"