AIX 5l Learning Outline/simple tutorial (3) (do not copy without permission)

Source: Internet
Author: User
Tags echo command

(Before resuming)

(7) automatically execute a job

1. Job Control
Pause a running process or job: ^ Z
Resume the pause task by running the BG command in the background.
Enable paused tasks or background processes to run at the frontend: FG command
View paused or background job: Jobs command (job number can be obtained)
The user does not end running after exiting the system: nohug
Once you exit the system, the jobs started by nohug cannot be updated in the jobs command display.
# Kill % job number (terminate the process of the specified job number)
# FG % job ID
# BG % job ID

# Nohug Command [arg...] [&] (run in the background when adding)
The output will be written to the nohug. Out file in the current directory. If there is no write permission, the output will be redirected to the $ home/nohug. Out file.
Eg. $ nohug find/-name myprg-Print &

2. At command
Read commands from standard input or script files and execute them at the specified time.
Generally, standard output and error output are sent to the user by email after at execution, unless the user is redirected.
At is only run once at the specified time. If it is not enabled, it cannot be executed. However, whether the user exits the system does not affect the AT command execution.

At [-c |-k |-S |-Q queue] [-M] [-F file] {-t date | time [Day] [increment]}

-C is executed using CSH, which is equivalent to-q f.
-K is executed using ksh, which is equivalent to-Q e.
-S bsh
-Q queue: puts a job in the specified queue. By default, the scheduled job is placed in queue A, while B, C, and D are
The name of the reserved queue. (B is a batch job. The command is read from the standard input. The time parameter is set
Specify the now keyword; C is a cron job; D is a sync job)
-M mail sending
-F file instead of standard input
-T date... specifies the running time.
Where Day is the day of the week, such as Sunday;
It can also be the full name of a month, such as December.
The pipeline operator can tell the command to the AT command for execution at time.
Eg. $ echo command | at time (time is the specified time)
You can also run the LS command to view all at jobs:
# Cd/var/spool/cron/atjobs
# Ls-l
[Essence: After the AT command is issued, a job number is assigned to the program or command specified in the AT command and queued in this directory. Therefore, you can view it using LS-L.]

-T:
Date Format:
[[CC] YY] mmddhhmm [. SS]
19 83 03180958. 25
20 05 11261709. 33
Year, month, day, hour, second
Time Format:
Am (in the morning, a is acceptable)
PM (afternoon, P is acceptable)
Zulu (Greenwich Mean Time)
You can also: noon (N), midnight (M), now (now)
$ At now next week now
$ At now + 38 days after 38 days
$ At noon tomorrow
$ At 3: 00 PM Friday next work

Use the AT command to display the created scheduled jobs in the current system:
$ At-L [-O] [job... |-Q queue]
| ---------------
|
| Job team column name
|
| + -- Display in chronological order
+ -- Displays the created job

$ At-N [user]
Eg. # At-N Johnson shows the number of files Johnson has in the user queue

$ At-R [-F] [-I] [job... |-u user]
-R: delete an existing job
-F disable deletion Verification
-I Interaction Mode
Job... job no.
-U User: deletes all jobs of the specified user (only available to the root user)
# Atrm job number (equivalent to: # At-r job number, used to delete jobs created by)
All jobs created by the AT command are executed by the cron service process at a specified time.
# ATQ [-c |-N] [user...] (displays the queue of jobs waiting for execution)
-C time sorting
-N: only job numbers are displayed.

The following two files jointly control the user's permissions to use the AT and batch commands:
/Var/adm/cron/at. allow (allowed)
/Var/adm/cron/at. deny (Forbidden)
Only the root user can modify, delete, and create two files.

The batch command solves the impact of system load bottlenecks on scheduled jobs.
Batch actually calls the at-B-M now command, which is generally in the same format as.
Automatically execute commands cyclically (cron process: automatically execute jobs at regular intervals or periodically execute jobs)
The cron process is started by the INIT process only once until the system is shut down.

Events completed by the cron process (defined in the/var/adm/cron/queuedefs file ):
(1) crontab command
(2)
(3) Batch
(4) Sync (system synchronization events, synchronous disk write operations)
(5) KSh or CSH
Check whether the cron process is running properly:
# Add the following record to the crontab file edited by crontab-E:
* ***/Bin/date, and then check the user mailbox
Check: # ps-Ef | grep cron to check whether the cron process is running. If not, check whether the following row of records exist in the/etc/inittab file.
Cron: 23456789: respawn:/usr/sbin/cron
If none, use the smitab command or VI to add upstream records;
Run the following command again: # telinit-Q (restart the cron process of the init process)
Run the ps command to check whether it runs normally.

To view which cron jobs have been created:
# Cd/var/spool/cron/crontabs
[Essence: the cron mechanism creates a crontab file for each user, uses the user name as the file name, and stores it in this directory]
# Ls-l

Skulker command: Delete Obsolete files that are no longer needed, mainly files in the/tmp directory, files earlier than the specified time, A. out files, core files, or Ed. Hup files. (Only run by the root user)
Skulker can be used in combination with the find and xargs commands to find files with specified conditions. (Use this command with Caution !)

/Usr/lib/smdemon. cleanu>/dev/null
Script File: used to clear the sendmail command queue and maintain the/var/spool/mqueue/log file.

Crontab file record format:
Minute Hour day_of_month month weekday command
0 ~ 59 0 ~ 23 1 ~ 31 day of each month ~ 12 0 ~ 6 (0 is Sunday) Shell Command or script

(1) from... to...: number connected with "-", table range, such as 1-5 indicates 1, 2, 3, 4, 5.
(2) A separate number indicates the time in which it belongs. If "month" is set to "6", it indicates that it is within June;
(3) separated by commas (,), indicating a single column, such as, 5
(4) * all valid values of Table No., for example, placing * on month indicates 1 ~ 12
Example: 0 0*5...
Indicates that the task is executed on the 1st day, 20th day, and 5th day of every month...
If the string contains % (except/%), % is a command before %, followed by standard input.
For example, if Johnson wishes a pleasant weekend to all users at every weekend, create a Johnson file under the/var/spool/cron/crontabs directory, and the Johnson user's crontab file is: /var/spool/cron/crontabs/Johnson, add the following records to this file:
0 16 ** 5/usr/sbin/wall % Happy weekend!

Add and modify cron jobs
Edit the crontab file: (1) manually edit the VI command (2) use the crontab Tool
# Crontab [-E |-L |-r |-v | file]
-E: edit the crontab file of the current user. If the crontab file does not exist, start the editing statement to create it.
-L display the contents of your crontab file
-R: Delete the user's crontab file from the crontabs directory.
-V: displays the time when a cron job is submitted.

You can use the crontab command in either of the following ways:
(1) manually create a text file, such as tempcronjobs, which includes the content required by the cron process. Then:
$ Crontab tempcronjobs
This command first checks the validity of the content of tempcronjobs. if valid, copy it to the/var/admn/cron/crontabs directory, use the username as the file name or overwrite the original crontab file of the current user.
(2) When crontab-E is used, it automatically creates or modifies the crontab file named by the current user name.
If the current user's crontab does not exist, it will create it in the/var/admn/cron/crontabs directory;
If it already exists, copy a copy of the original crontab file to the/tmp directory, and then edit the copy. After editing, check whether the copy content is valid, overwrite the original file with a copy.
Show the contents of the crontab file:
$ Crontab-l
Delete A cron job and use crontab-e to delete the row containing the job to be deleted. (You can also modify it using VI)

[Note: To prevent the root user from using the crontab-R command, it will delete the/var/spool/cron/crontabs/root file, this file contains routine scheduled jobs such as diagnosing hardware errors and checking system faults. Once deleted, the system security is threatened. At this time, you can only restore it through the previous backup]

Disable or allow some users to use the crontab or at command:
Create the cron. allow, cron. deny, at. allow, at. deny files in the/usr/ADM/cron directory.
Cron. allow and cron. deny do not exist. Only the root user can use the crontab command. If the relevant files exist, the priority principle exists. *. Allow takes precedence over *. Deny.

All the activity logs of the cron process are recorded in the/var/adm/cron/log file. The cron log file should be cleaned regularly to avoid being too large and occupying space.

Chapter 18 Network File System NFS
NFS: Network File System: A Network File System developed by Sun Microsystems in 1984. It is a de facto industrial standard, supported by UNIX and Windows series.
NFS is a distributed file system that allows users to access files and directories on a remote system. You can create, delete, and read/Write Remote files and directories locally using operating system commands and SET related properties. By using RPC (Remote Procedure Call), you are not limited by the machine type, operating system, and network structure.
NFS is based on the Client/Server mode. Before accessing the file system exported by the server, the client must install it locally.
Remote resources are generally written in the format of hostname: pathname. hostname is the host name of the NFS server, and pathname is the absolute path of the exported directory on the server.
Mount point: directory of the Remote resource installed on the client.
The specific NFS protocol is the RPC (Remote process call) protocol and XDR (external data representation) protocol. RPC transmits data packets over the network through UDP and TCP, so NFS also depends on TCP/IP .. RPC and XDR are a set of TCP/IP-based application programming interfaces.
The NFS protocol is stateless. The main function of the Portmap waiting process is to convert the RPC program number to the Internet port number. It is started by the/etc/rc. TCPIP command file, and the standard RPC process is usually started by the inetd process.

Start the NFS service: # mknfs [-I |-N |-B]
The [startup condition]/etc/exports file must exist. Otherwise, the nfsd and rpc. mountd processes will not start.
If the file does not exist, use # Touch/ECT/exports to create an empty/etc/exports file and then start the NFS service.

# Mknfs-N (-N immediately executes the/etc/rc. NFS command file)
To run the/etc/rc. NFS command file when the system starts, add a record for starting the NFS service in the/etc/inittab file:
# Mknfs-I (-I adds a record to the/etc/inittab file)
To add an Automatic startup record and execute it immediately:
# Mknfs-B (this is the default parameter of mknfs)

Startsrc can also start the NFS process, and the NFS process can also be started separately.
For example: # startsrc-s RPS. mountd (start the rpc. mountd process)
To start all processes of NFS, you can: # startsrc-G NFS

Disable the NFS service: # rmnfs [-I |-N |-B] (the parameters have similar meanings. The overall function is opposite to that of mknfs)

Check whether the NFS process is running: # lssrc-G NFS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.