Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
debian:cron [2020/04/15 10:51] – erreur32 | debian:cron [2022/11/08 16:43] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== | + | ====== |
- | + | ||
+ | ====== all_ban.sh ====== | ||
+ | |||
+ | |||
#!/bin/bash | #!/bin/bash | ||
- | |||
# System-wide crontab file and cron job directory. Change these for your system. | # System-wide crontab file and cron job directory. Change these for your system. | ||
CRONTAB='/ | CRONTAB='/ | ||
CRONDIR='/ | CRONDIR='/ | ||
- | |||
# Single tab character. Annoyingly necessary. | # Single tab character. Annoyingly necessary. | ||
tab=$(echo -en " | tab=$(echo -en " | ||
- | |||
# Given a stream of crontab lines, exclude non-cron job lines, replace | # Given a stream of crontab lines, exclude non-cron job lines, replace | ||
# whitespace characters with a single space, and remove any spaces from the | # whitespace characters with a single space, and remove any spaces from the | ||
Ligne 22: | Ligne 21: | ||
done; | done; | ||
} | } | ||
- | |||
# Given a stream of cleaned crontab lines, echo any that don't include the | # 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 | # run-parts command, and for those that do, show each job file in the run-parts | ||
Ligne 29: | Ligne 27: | ||
while read line ; do | while read line ; do | ||
match=$(echo " | match=$(echo " | ||
- | |||
if [[ -z " | if [[ -z " | ||
echo " | echo " | ||
Ligne 35: | Ligne 32: | ||
cron_fields=$(echo " | cron_fields=$(echo " | ||
cron_job_dir=$(echo | cron_job_dir=$(echo | ||
- | |||
if [[ -d " | if [[ -d " | ||
for cron_job_file in " | for cron_job_file in " | ||
Ligne 44: | Ligne 40: | ||
done; | done; | ||
} | } | ||
- | |||
# Temporary file for crontab lines. | # Temporary file for crontab lines. | ||
temp=$(mktemp) || exit 1 | temp=$(mktemp) || exit 1 | ||
- | |||
# Add all of the jobs from the system-wide crontab file. | # Add all of the jobs from the system-wide crontab file. | ||
cat " | cat " | ||
- | |||
# Add all of the jobs from the system-wide cron directory. | # Add all of the jobs from the system-wide cron directory. | ||
cat " | cat " | ||
- | |||
# Add each user's crontab (if it exists). Insert the user's name between the | # Add each user's crontab (if it exists). Insert the user's name between the | ||
# five time fields and the command. | # five time fields and the command. | ||
Ligne 61: | Ligne 53: | ||
sed --regexp-extended " | sed --regexp-extended " | ||
done < <(cut --fields=1 --delimiter=: | done < <(cut --fields=1 --delimiter=: | ||
- | |||
# Output the collected crontab lines. Replace the single spaces between the | # Output the collected crontab lines. Replace the single spaces between the | ||
# fields with tab characters, sort the lines by hour and minute, insert the | # fields with tab characters, sort the lines by hour and minute, insert the | ||
Ligne 70: | Ligne 61: | ||
sed " | sed " | ||
column -s" | column -s" | ||
- | |||
rm --force " | rm --force " | ||
+ | {{tag> |