Scheduling: Schedulinghas three types:
he atcommand reads from standard input the names of commands to be run at a later time and allows you to specify when the commands should be run.
The at command mails you all output from standard output and standard error for the scheduled commands, unless you redirect that output. It also writes the job number and the scheduled time to standard error.
When the at command is executed, it retains the current process environment. It does not retain open file descriptors, traps, and priority.To schedule a job to run at a later time, you must specify a time to start the job. You may specify the time by using either the -tDate flag or the Time, Day, and Increment parameters. At most, 60 jobs can be scheduled in any given run queue at the granularity of one per second. If more jobs than can be handled are submitted, for every job beyond 60, a file _at<pid> is created in /var/spool/cron/atjobs/ which can be safely deleted by the end user.
The Datevariable to the -t flag is specified using the following format:
The digits in the Date variable are defined as follows:
|#at||submits a job for cron to run at a specific time in the future
(at -f /home/root/bb_at -t 2007122503)
|#echo “<command>” | 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|
When entering a command name as the last item on the command line, a full path name must be given if the command is not in the current directory, and the at command will not accept any arguments.
2. Crontab:Submits, edits, lists, or removes cron jobs.
crontab [-e [UserName] | -l [UserName] | -r [UserName] | -v[UserName] | File ]
The crontab command submits, edits, lists, or removes cron jobs. A cron job is a command run by the cron daemon at regularly scheduled intervals. To submit a cron job, specify the crontab command with the -e flag. The crontab command invokes an editing session that allows you to create a crontab file. You create entries for each cron job in this file. Each entry must be in a form acceptable to the cron daemon. For information on creating entries, see The crontab File Entry Format.
Only the root user or the owner of the crontab file can use UserName following the -e, -l,-r, and x-small;”>-v flags to edit, list, remove, or verify the crontab file of the specified user.
Controls on Using the crontab Command
/var/adm/cron/cron.allow File containing users who allowed cron service
/var/adm/cron/cron.deny File containing users denied cron service
/var/adm/cron/at.allow File containing users who allowed at service
/var/adm/cron/at.deny File containing users denied at service
# crontab –e This command will open Vi editor and after making changes user can save and quit.
# crontab –l Command will list all the jobs scheduled.
# crontab –r this command will remove all the cron jobs. You should be very careful in running these commands in production environment.
A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields separated by spaces or tabs in the following form:
minute hour day_of_month month weekday command
These fields accept the following values:
|minute||0 through 59|
|hour||0 through 23|
|day_of_month||1 through 31|
|month||1 through 12|
|weekday||0 through 6 for Sunday through Saturday|
|command||a shell command|
e.gSep 1 12:30 AM is represented as:
30 00 1 9 * <command>
The batch command reads from standard input the names of commands to be run at a later time and runs the jobs when the system load level permits. The batch command mails you all output from standard output and standard error for the scheduled commands, unless you redirect that output. It also writes the job number and the scheduled time to standard error.
The batch command is equivalent to entering the at -q b -m now command. The -q b flag specifies the at queue for batch jobs.
|/usr/bin/batch||Contains the batchcommand.|
|/bin/batch||Symbolic link to the batch command.|
|/var/adm/cron||Indicates the main crondaemon directory.|
|/var/spool/cron/atjobs||Indicates the spool area.|