first, control before and after the work
Jobs: Lists the background or paused jobs for the current environment
FG, BG, kill: Controls the specified job, and the job uses the%+ job number to specify
Nohup: Run a job that even if the account logout is not killed, but is taken over by the Init process
Second, at command-pre-Specify a single job execution
#at [-C |-k |-s-q quene] [-M] [-f File] {-T Date | Time [day] [increment]}
1) Three formats for running at commands
A) #at time
Command1
Command2
... ...
Ctrl+d (end command input)
#
b) #echo command| At time (tell the command to at by a pipe break)
c) #at-F file Time (Specifies the command to execute the file in the moment)
2) The time format of the recognized
A) The format of the date parameter--[[CC] YY] mmddhhmm [. SS]
CC: Century; YY: The last two digits of the year; MM: month of the Year (01~12); DD: Day of January (01~31); HH: Hour of the day (00~23); MM: Minutes in one hour (00~59); SS: Seconds in one minute (00~59)
CC and yy is optional, if YY given and CC is not given, then there are the following rules: (1), 99>=yy>=70, then cc=19;37>=yy>=00, then cc=20.
The SS default is 00
b) Time [day] [increment] Format
The time parameter is a number followed by a suffix, if time is a two-digit number, then at will treat it as an hour, four digits will be the hour and minute, if the four digits separated by a colon (:), then the meaning is hh:mm. The suffix can be am, PM, Zulu,zulu is GMT.
Time also has some special parameter forms as follows: Noon, midnight, now, A (representing AM), P (for PM), N (for Noon), M (for Midnight)
Time is followed by a day parameter: used to represent a month name and a day number (which can take one year before the comma), or a date that is one weeks. The default is the day after the month, and if Day is 2 or more characters, it is expressed as a date of the week, such as Sunday; If 3 characters are generally indicated as months, such as June. If the date is not given, then day defaults to today or tomorrow as a default parameter value (time is only today, if time is past, tomorrow).
The parameter increment is used to change the time and date parameters, but is a plus sign (+) followed by a number and a unit. The format is "+n Units", where Units can be minute[s], hour[s], Day[s], Week[s], Mouth[s], year[s], etc.
The following are the correct representations:
#at 0820----> 8 o'clock in the morning 20 daily job execution
#at 0820 am----> Daily 8 o'clock in the morning 20 execution of the job
#at 08:20 AM July----> on July 26 8 o'clock in the morning 20 execution of the job
#at 7 pm Monday----> Monday 7 o'clock in the afternoon execute job
#at now next week----> doing homework at this time next week
#at now +38 days----> Execute the job at this time after 38 day
#at noon Tomorrow----> doing homework tomorrow Noon
#at Friday next week----> to execute a Job 3 o'clock in the afternoon next Friday
The last line is the job number and the execution time date at which the at returns. The job number consists of three parts:root.996455160.a--< user name >.< Job ID >.< Job type, and the job is assigned sequentially by the system, regardless of the process ID.
c) Show/delete at job
#at-L [-o] [Job |-Q Queue]
#at-N [User]
#at-R [-f] [-i] Job
#at-R [-f] [-i]-u User
3) control user use at command
Together, the two files of /var/adm/cron/at.allow and /var/adm/cron/at/deny control which users can use the AT command and the batch command which users cannot, Only the root user can create and edit these files.
If the /var/adm/cron/at.allow file exists, only the user who appears in the file has the right to execute the AT command, if the /var/adm/cron/at/deny file exists, Then the user who does not appear in this has the right to execute the AT command
In either case, the user cannot use the AT command:
A) both allow and deny files do not exist
b) Allow file is empty
c) The deny file exists, but the user name records where
third, Batch command
With the AT command, when the at job is between the specified executions, the job is started directly regardless of the current system load, and the batch command may be useful if the pre-executed job takes up a large amount of system time. The batch command reads the command from the standard input, submits a batch of jobs to the system, and then puts the job in a queue, depending on the system load and the opportunity to begin execution. The simple batch command is equivalent to At-b-M now.
If the batch or At-b command does not take time, the job immediately queues in the queue and executes as soon as the system load is allowed, and if the time parameter is taken, the job is run after the system load is allowed.
iv. cron--Periodic automatic execution of operations
1) Cron process
The cron background service process is started by the Init process. It is a daemon process, when the system starts, only need to start once, after startup, will check the crontab file, when the Crontab tool modified the file, will send a crontab file to the crontab process has changed the message, The cron process then re-reads the crontab file
The cron process executes the command according to the contents of the record in the crontab file, unless the standard input and error output of the cron job is redirected, and the cron process sends the standard output and error output to the logged-on user in the form of a message. If an incorrect record is specified in the crontab file, the cron process does not execute that job. You can use CRONTAB-E to edit the crontab file
2) crontab file
A) The crontab file records the command information executed by the CRON process on the specified date and time, and the cron mechanism will create a crontab file for each user, with the user name as the file name for the crontab file located in/var/spool/ The cron/crontabs/directory.
b) format of crontab file records
minute hour day_month month weekday command
which
minute:00~59
Hour:00~23
Day_month:1~31
Month:1~12
weekday:0~6,0 for Sunday
Command:shell command
Special Instructions:
(1): Two numbers with "-" connection, which represents all values within a number, eg: "3-6" means 3, 4, 5, 6
(2): An individual number, representing the range, eg:month field write 7, expressed in July
(3): comma-separated list of numbers representing a set of values specified by each number, eg: "3,6" for 3, 6
(4): A *, representing all legal values
(5): Days in the date can be determined by two fields, respectively Day_month and weekday, if two fields have a specified number, then the command executes when the date matches any one of the two fields.
(6): command can be a single order or a shell script consisting of multiple commands. If the string contains "%" (unless the backslash "\", or "\%") is used, then the cron process considers that all characters before the% is the standard input part of the command, which is all characters behind the%.
(7): A blank line cannot appear in the crontab file, otherwise the cron process will make an error, in which the lines that appear in the # are comment lines.
(8): The control of the two files,/var/adm/cron/cron.allow and /var/adm/cron/cron.deny , also applies to the cron process. The specific mode of action can refer to the instructions of the two control files under the AT command.
c) Cron log
The cron process records all of its activities in the /var/adm/cron/log file. Querying the log can help users track problems that are puzzling and related to debugging jobs.
When Cron runs a job, it creates temporary files in the/tmp directory that begin with the "Crout" string, which is automatically deleted when the job finishes, and if the files still exist, the cron process does not run the job successfully. There may be a problem with the job.
The 13th chapter automates the execution of jobs