debian:cron

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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] erreur32debian:cron [2022/11/08 16:43] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
-====== Check ALL cron on Debian ====== +====== SCRIPT: list  ALL cron on Debian ======
- +
    
 +====== 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='/etc/crontab'   CRONTAB='/etc/crontab'
   CRONDIR='/etc/cron.d'   CRONDIR='/etc/cron.d'
- 
   # Single tab character. Annoyingly necessary.   # Single tab character. Annoyingly necessary.
   tab=$(echo -en "\t")   tab=$(echo -en "\t")
- 
   # 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 "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+')         match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+')
- 
         if [[ -z "${match}" ]] ; then         if [[ -z "${match}" ]] ; then
             echo "${line}"             echo "${line}"
Ligne 35: Ligne 32:
             cron_fields=$(echo "${line}" | cut -f1-6 -d' ')             cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
             cron_job_dir=$(echo  "${match}" | awk '{print $NF}')             cron_job_dir=$(echo  "${match}" | awk '{print $NF}')
- 
             if [[ -d "${cron_job_dir}" ]] ; then             if [[ -d "${cron_job_dir}" ]] ; then
                 for cron_job_file in "${cron_job_dir}"/* ; do  # */ <not a comment>                 for cron_job_file in "${cron_job_dir}"/* ; do  # */ <not a comment>
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 "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"    cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}" 
- 
   # Add all of the jobs from the system-wide cron directory.   # Add all of the jobs from the system-wide cron directory.
   cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}"  # */ <not a comment>   cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}"  # */ <not a comment>
- 
   # 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 "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"         sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"
   done < <(cut --fields=1 --delimiter=: /etc/passwd)   done < <(cut --fields=1 --delimiter=: /etc/passwd)
- 
   # 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 "1i\mi\th\td\tm\tw\tuser\tcommand" |     sed "1i\mi\th\td\tm\tw\tuser\tcommand" |
     column -s"${tab}" -t     column -s"${tab}" -t
- 
   rm --force "${temp}"    rm --force "${temp}" 
  
    
 +{{tag>tips cron script}}
  • debian/cron.1586940683.txt
  • Dernière modification : 2020/04/15 10:51
  • de erreur32