Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
debian:cron [2016/05/03 00:17] – modification externe 127.0.0.1 | debian:cron [2022/11/08 16:43] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== SCRIPT: list ALL cron on Debian ====== | ||
+ | |||
+ | ====== all_ban.sh ====== | ||
+ | |||
+ | #!/bin/bash | ||
+ | # System-wide crontab file and cron job directory. Change these for your system. | ||
+ | CRONTAB='/ | ||
+ | CRONDIR='/ | ||
+ | # Single tab character. Annoyingly necessary. | ||
+ | tab=$(echo -en " | ||
+ | # Given a stream of crontab lines, exclude non-cron job lines, replace | ||
+ | # whitespace characters with a single space, and remove any spaces from the | ||
+ | # beginning of each line. | ||
+ | function clean_cron_lines() { | ||
+ | while read line ; do | ||
+ | echo " | ||
+ | egrep --invert-match ' | ||
+ | sed --regexp-extended " | ||
+ | sed --regexp-extended "s/^ //" | ||
+ | done; | ||
+ | } | ||
+ | # Given a stream of cleaned crontab lines, echo any that don't include the | ||
+ | # run-parts command, and for those that do, show each job file in the run-parts | ||
+ | # directory as if it were scheduled explicitly. | ||
+ | function lookup_run_parts() { | ||
+ | while read line ; do | ||
+ | match=$(echo " | ||
+ | if [[ -z " | ||
+ | echo " | ||
+ | else | ||
+ | cron_fields=$(echo " | ||
+ | cron_job_dir=$(echo | ||
+ | if [[ -d " | ||
+ | for cron_job_file in " | ||
+ | [[ -f " | ||
+ | done | ||
+ | fi | ||
+ | fi | ||
+ | done; | ||
+ | } | ||
+ | # Temporary file for crontab lines. | ||
+ | temp=$(mktemp) || exit 1 | ||
+ | # Add all of the jobs from the system-wide crontab file. | ||
+ | cat " | ||
+ | # Add all of the jobs from the system-wide cron directory. | ||
+ | cat " | ||
+ | # Add each user's crontab (if it exists). Insert the user's name between the | ||
+ | # five time fields and the command. | ||
+ | while read user ; do | ||
+ | crontab -l -u " | ||
+ | clean_cron_lines | | ||
+ | sed --regexp-extended " | ||
+ | done < <(cut --fields=1 --delimiter=: | ||
+ | # Output the collected crontab lines. Replace the single spaces between the | ||
+ | # fields with tab characters, sort the lines by hour and minute, insert the | ||
+ | # header line, and format the results as a table. | ||
+ | cat " | ||
+ | sed --regexp-extended " | ||
+ | sort --numeric-sort --field-separator=" | ||
+ | sed " | ||
+ | column -s" | ||
+ | rm --force " | ||
+ | |||
+ | |||
+ | {{tag> |