Zu den Hauptinhalten
  • Bestellungen schnell und einfach aufgeben
  • Bestellungen anzeigen und den Versandstatus verfolgen
  • Erstellen Sie eine Liste Ihrer Produkte, auf die Sie jederzeit zugreifen können.

How to Configure Cron Jobs on RedHat Enterprise Linux (RHEL) 6

Zusammenfassung: This article provides information on how to configure cron jobs on RedHat Enterprise Linux (RHEL) 6.

Dieser Artikel gilt für Dieser Artikel gilt nicht für Dieser Artikel ist nicht an ein bestimmtes Produkt gebunden. In diesem Artikel werden nicht alle Produktversionen aufgeführt.

Symptome

This article provides information on how to configure cron jobs on RedHat Enterprise Linux (RHEL) 6.

Cron jobs allow system administrators to schedule tasks. There are various ways you can configure these scheduled tasks. This article will cover using the 'cron' directories and using 'crontab'.



 

 

Table of Contents:

1. Cron Directories
2. Crontab


 

1. Cron Directories

  • There are four cron directories :
    • /etc/cron.hourly/
    • /etc/cron.daily/
    • /etc/cron.weekly/
    • /etc/cron.monthly/
       
  • Scripts in these directories will be executed on recurring basis (every hour, day, week, or month)
  • Perfect for scheduled tasks that do not need to be run on a specific day, specific time, etc.
  • Copy your script into the corresponding folder
  • Ensure scripts have the file permissions of 755 or -rwxr-xr-x
  • # chmod 755 scriptfile.sh
  • Default :
    • /etc/cron.daily starts at 0305 (3:05 AM)
    • /etc/cron.weekly starts at 0325 (3:25 AM)
    • /etc/cron.monthly starts at 0345 (3:45 AM)
       
  • View your current configuration :
  • # cat /etc/anacrontab
  • Use your favorite editor to edit '/etc/anacrontab'
  • Change your configuration :
  • What time the scripts will be executed in these directories :

 


 

2. Crontab

  • System administrators can use crontab to create cron jobs to schedule tasks to execute at a specific date and time
  • Using crontab is the same as you would use the 'vi' editor
  • Usage :
  • Edit cron jobs :
    • # crontab -e
       
  • List cron jobs for current logged in user :
  • # crontab -l
  • # crontab -l -u username
Note: Replace 'username' with corresponding user.
  • # crontab -r
  • # crontab -r -u username
Note: Replace 'username' with corresponding user.
  • List cron jobs for a different user :
  • Remove cron jobs for current logged in user :
  • Remove cron jobs for a different user :
  • M H D Mo W /path/to/script
    • M = Minute (00 to 59)
    • H = Hour (00 to 23)
    • D = Day of month (01 to 31)
    • Mo = Month (01 to 12)
    • W = Day of week (0 to 6 .. 0 = Sunday)
       
  • Use * to imply every hour, day, etc.
  • Example :
  • 30 02 15 6 * /root/scriptfile.sh
  • Executes '/root/scriptfile.sh' on June 15th at 2:30AM
  • 30 02 * * 0 /root/scriptfile.sh
  • Executes '/root/scriptfile.sh' every Sunday at 2:30AM
  • Example :
    • 30 02,14 15 6 * /root/scriptfile.sh
    • Executes '/root/scriptfile.sh' on June 15th at 2:30AM and 2:30PM
       
  • Example :
    • 30 02-05 * * 0 /root/scriptfile.sh
    • Executes '/root/scriptfile.sh' every Sunday at 2:30AM, 3:30AM, 4:30AM, and 5:30AM
       
  • @yearly - execute script every year
  • @monthly - execute script every month
  • @weekly - execute script every week
  • @daily - execute script every day
  • @hourly - execute script every hour
  • @reboot - execute script every reboot
  • Use these variables instead of the M H D Mo W format
    • Example :
      • @monthly /root/scriptfile.sh
      • Executes '/root/scriptfile.sh' on the first day of every month
         
  • Example :
  • Use , for multiple hours, days, etc.
  • Use - to span hours, days, etc.
  • Additional variables :
  • Formatting entries :

 

 

Back to Top


Ursache

-

Lösung

-

Betroffene Produkte

Red Hat Enterprise Linux Version 6
Artikeleigenschaften
Artikelnummer: 000177157
Artikeltyp: Solution
Zuletzt geändert: 13 Aug. 2024
Version:  7
Antworten auf Ihre Fragen erhalten Sie von anderen Dell NutzerInnen
Support Services
Prüfen Sie, ob Ihr Gerät durch Support Services abgedeckt ist.