Linux Learning - Cron/Anacron/At

###Cron###
Features:
 1. Job Scheduler
  a. minutely
  b. hourly
  c. daily
  d. monthly
  e. yearly
Note: Fields: a-e are specified as per the order above in appropriate config. file


 2. Assumes computer is always on unlike: anacron
 3. Maintains: global and per-user schedules
 4. /var/spool/cron - stores crontabs for: /etc/passwd users or LDAP or otherwise
 5. Checks ALL config files every minute, including: /etc/anacrontab
 6. Supplies 'crontab' utility to manage jobs
 7. Runs in ALL multi-user modes. Does NOT execute in: Single-User (1) mode


Tasks:
 1. Analyze current cron setup
  a. 'ps -ef | grep cron'
  b. '/etc/crontab'


 2. Define system-wide job
  a. '*/1 * * * * linuxcbt /usr/bin/uptime >> /home/linuxcbt/uptime.stat'


 3. Define per-user job
  a. 'crontab -e' - run as user principle: 'linuxcbt'


 4. Manipulate 'linuxcbt's' job as 'root'
  a. 'crontab -e -u linuxcbt' - run as 'root' - edits user's job(s)
  b. 'crontab -l -u linuxcbt' - run as 'root' - lists user's job(s)


 4. Restrict Cron-access
  a. '/etc/cron.allow' - add 'linuxcbt to list - User MUST be on the list in order to submit jobs to 'cron'
  b. '/etc/cron.deny' - add 'linuxcbt2' to list


###Anacron###
Features:
 1. Runs jobs once per day during an allowed interval
 2. Assumes computer is NOT always on, unlike: Cron
 3. Facilitates delays in starting jobs - reduces resource contention
 4. Maintains one schedule: '/etc/anacrontab'
 5. Requires little-to-no intervention; handled by the system


Tasks:
 1. Examine: '/etc/anacrontab'






###'at' and 'batch'###
Features:
 1. One-off job schedulers
 2. 'at' runs based on time schedule
 3. 'batch' runs based on system-utilization stats: default < 0.8 for load average


Tasks:
 1. Use 'at' to run jobs
  a. 'at 15:58'
  b. 'at 16:01'
  c. 'at -f at.job.1 16:02'
  d. 'at now + 1 day' - runs job 1-day from now (time submitted to job-queue)


 2. Use 'batch' to run jobs
  a. 'batch' - supply instructions on STDIN
Note: 'batch' accepts no command-line options
Note: 'at' runs the jobs on behalf of 'batch'
Note: 'batch' is simply a special invocation of 'at'

你可能感兴趣的:(Linux Learning - Cron/Anacron/At)