Scheduling Cron & At Jobs


The cron daemon, which translates to Chronological Data Event Monitor, is a program that schedules jobs to run automatically at a specific time and date. The /etc/inittab file contains all the AIX startup programs, including the cron daemon. The init process in AIX starts the cron daemon, or cron, from the inittab file during the initialization process of the operating system.

You can submit jobs, or events, to cron by doing one of the following:

Use the at and batch facilities to submit jobs for one-time execution.
Use the crontab files to execute jobs at regularly scheduled intervals (hourly, daily, weekly, and so on).

By default, cron can concurrently run 100 events of equal importance. The /usr/adm/cron/queuedefs file allows you to change this schedule.


| |    |   |
| |    |   wait period (in seconds)
| |    nice value
| jobs

At regularly scheduled intervals, cron looks for and reads the crontab files that are located in the directory /var/spool/cron/crontabs.

These files contain jobs submitted by users. For example, the file /var/spool/cron/crontabs/surya contains Surya's jobs that are scheduled to be run by cron

The cron daemon reads the files in the /var/spool/cron/crontabs directory. The files in this directory are named for the individual users.

When changes are made to the files in the crontabs directory, the cron daemon must be notified to reread the files

/var/adm/cron/logcron daemon creates a log of its activities
/var/adm/cron/cron.denyAny user can use cron except those listed in this file
/var/adm/cron/cron.allowOnly users listed in this file can use cron (root user included)
crontab -l Lists the contents of your current crontab file
crontab -eEdits your current crontab file (when the file saved, the cron daemon is automatically refreshed.)
crontab -rRemoves your crontab file from the crontab directory
crontab -vcheck crontab submission time
crontab mycronfilesubmit your crontab file to /var/spool/cron/crontabs directory

crontab file format:

minute    hour    day_of_month    month        weekday        command
0-59      0-23    1-31            1-12        0-6 Sun-Sat     shell command

* * * * * /bin/ schedule a job to run every minute
0 1 15 * * /fullbackup 1 am on the 15th of every month
0 0 * * 1-5 /usr/sbin/backup start the backup command at midnight, Mo - Fr
0,15,30,45 6-17 * * 1-5 /home/script1execute script1 every 15 minutes between 6AM and 5PM, Mo - Fr
0 1 1 * * /tmp -name 'TRACE*' -mtime +270 -exec rm {} \\; >/dev/null 2>&1 it will delete files older than 9 months (\\; <-- because="" correctly="" double="" interpret="" needed="" td="" to="">


/at submits a job for cron to run at a specific time in the future (at -f /home/root/bb_at -t 2007122503)
echo "" | at now this starts in the background (and you can log off)
at now +2 mins banner hello > /dev/pts/0 (at now + 1 minute,at 5 pm Friday )
/var/adm/cron/at.deny allows any users except those listed in this file to use the at command.
/var/adm/cron/at.allow allows only those users listed in this file to use the at command (including root).
at -l Lists at jobs
atq [user] Views other user's jobs (Only root can use this command.)
at -r Cancels an at job
atrm job Cancels an at job by job number
atrm user Cancels an at job by the user (root can use it for any user; users can cancel their jobs.)
atrm Cancels all at jobs belonging to the user invoking the atrm command
batch submits a job to be run in the background when the processor load is low

0 Comment "Scheduling Cron & At Jobs"

Post a Comment

Comment here