Functions of the kernel: process management, file system, network function, memory management, driver, security Full function etc.
Process Management:
System priority: The smaller the number, the higher the priority
Real-time Priority: 99-0, highest value maximum priority
Nice value: 20 to 19, corresponding to system priority 100-139 or 99
Linux Kernel: Preemptive multi-tasking
Process Type:
Daemon: daemon, process initiated during system boot, and terminal-independent process
Foreground process: terminal-related, process initiated through terminal
Note: The two can be converted to each other
Process Status:
Operating state: Running
Ready state: Readiness
Sleep state:
Interruptible: interruptable
Non-disruptive: uninterruptable
Stop state: Stopped, paused in memory, but not dispatched unless manually started
Zombie State: Zombie, end process, child process does not close before parent process ends
The difference between a process and a thread:
A process can have multiple threads, a CPU can run only one process,
Threads can share resources, including network resources, memory resources
Process Management tools:
Pstree-p: View process Tree-P view PID
PS: View terminal information
Default display of processes in the current terminal
? A option includes all processes in the terminal
? The x option includes a process that does not link the terminal
? The U option displays information about the process owner
? The F option shows the parent process of the process
? O Properties ... option to display customized information
PID, Comm,%cpu,%mem, state, TTY, Euser, Ruser
pidof command: View PID for running commands
Stat: Process Status
R S D T Z L N <
Interruptible sleep Stop Zombie process multithreading high priority
Common combination:-ef
-e: Show All Processes
-F: Display full format program information
Common combination:-EFH
-F: Show process information in a more complete format
-H: Show process-related information in process-level format
Nice command:
Nice ten PID
Renice-n PID Adjustment Process Priority
Uptime: Displays the current time, and the system average load
Top command:
-D #: Specifies the refresh interval, which defaults to 3 seconds
-B: In batch mode (one page is displayed at a time)
-N #: Shows how many batches (such as showing 3 pages on the exit meaning)
Sort:
P: As percentage of CPU occupied,%cpu
M: Occupy memory percentage,%MEM
T: Cumulative CPU Duration, time+
The first message shows:
Uptime information: l command
Tasks and CPU information: T command
CPU Display: 1 (digital)
Memory Information: M command
Exit Command: Q
Modify Refresh time interval: s
Terminates the specified process: K
Save File: W
Top column information Introduction; Process view comparison easy to remember.
Htop command: yum-y install from Fedora-epel source installation Htop
Vmstat: Virtual Memory information
Vmstat 2 5: Show every 2 seconds, show five end
Iostat: Statistics CPU and device IO information
Iostat 2 5:
System Monitoring tools:
Glance
Server mode:
Glances-s-B ipaddr
IPADDR: Indicates which address of the listening machine
Client mode:
Glances-c ipaddr
IPADDR: Server-side address to connect to
Dstat: Instead of Vmstat,iostat, the function is very powerful.
-C: Display CPU-related information
-D: Show disk-related information
-G: Display page related statistics
-M: Display Memory related statistics
-N: Display network-related statistics
-P: Show process-related statistics
-R: Displays statistics related to IO requests
-S: Show swapped related statistics
Kill command:
Send a control signal to the process to achieve the management of the process, each signal corresponds to a number, the signal name begins with the sig (can be omitted) is not case-sensitive
Show current system available signals: Kill–l,trap-l
Common signal: Man 7 signal
1) SIGHUP: No need to close the process and let it reread the configuration file
2) SIGINT: Abort the running process, equivalent to CTRL + C
3) Sigquit: equivalent to Ctrl+\
9) SIGKILL: Force kills a running process
SIGTERM: Terminating a running process
Sigcont: Continue Running
SIGSTOP: Background hibernation
How to specify the signal:
(1) Digital identification of the signal: 1, 2, 9
(2) abbreviated name of signal: HUP
Example: kill-9 pid kill-1 PID
Job Management:
Job Control for Linux
Front-end operation: Through the terminal start, and after the start has occupied the terminal;
Background jobs: Can be started through the terminal, but after the boot into the background to run (release terminal)
? How do I get my job running in the background?
(1) Running jobs: Ctrl + Z (this action causes the process to hibernate)
(2) Jobs not yet started: # COMMAND & (This operation runs in the background)
? Background job is sent to the background, but it is still related to the terminal; exit the terminal, close
Background jobs. If you want to send back to the background, peel off the relationship with the terminal
# nohup COMMAND & #screen; COMMAND
? View All jobs:
# jobs
? Job Control: The background job will have a number, directly specify the number also line
# FG [[[%]job_num]: Bring the specified background job back to the foreground
# BG [[%]job_num]: Allow jobs sent to the background to continue running in the background
# Kill [%job_num]: terminates the specified job
Run in parallel:
Method 1 (write three scripts, put in a script to run, after each script with &)
VI all.sh
f1.sh&
f2.sh&
f3.sh&
? Method 2
(f1.sh&);(f2.sh&);(f3.sh&)
? Method 3
{f1.sh& f2.sh& f3.sh&}
Task Schedule:
linux Task schedule, recurring task execution
? Perform a task at some point in the future
at
batch: The system chooses its own idle time to perform the tasks specified here
? periodically run a task
&NB Sp cron
At: Depends on the package, the exam when similar package will be dug pit, need to manually start the service, otherwise do not take effect
rpm-q at : Query package name
RPM-QL at &N Bsp : Query the installation package path
service ATD status : see if the current service is starting sta RT and stop, temporary start
chkconfig –list ATD: See if Boot is on
&NBSP;CHKCONFIF –level 5 ATD on/off : Set boot on mode 5 or close Help View Help
CENTOS7:
&NBSP;SYSTEMCTL & nbsp is-enabled ATD : View ATD start automatically next time
&NBSP;SYSTENCTL enabled ATD : Next launch Auto start
systenctl disable ATD : Next boot does not start automatically
At time: command format, followed by times, Ctrl+d end
At-l: Viewing Scheduled Tasks
at-d #: Delete The specified scheduled task number
AT-C #: View task plan contents, directory in/var/spool/at/
At-f *.text Time: Write multiple task plans to a file call
AT-M: When the task is completed, the user will be sent a message, even if there is no standard output
Scheduled task results are sent as messages, and it is recommended to use redirection to resolve >/dev/null
Simultaneous scheduled tasks support parallel runs.
At.deny and At.allow/et/at.deny default/etc/at.allow not present
At.deny blacklist, to be effective premise, At.allow does not exist, the whitelist has the highest priority
At.allow Whitelist, only whitelist users may perform at, default does not exist, if present, At.deny fail, priority high
If none exists, only root can perform an at
If none of the two files exist, only the root row can execute the AT command
Recurring Task schedule:
cron: and at, you need to query the path and start the service, or boot up
&NBSP;RPM-QA cron*: & nbsp; you can search with wildcards;
Ensure Crond daemon is running:
CentOS 7:
SYSTEMCTL status Crond
CentOS 6:
service Crond status
? Schedule Scheduled tasks to be submitted to Crond for automatic operation at a specified time
System Cron Task: System maintenance Job
/etc/crontab
User cron task:
& nbsp crontab command
? log:/var/log/cron
Periodic plan is sensitive to symbols, such as%, Call the script as recommended, otherwise you will need to add single quotation marks;
Vim/etc/crontab
Time notation:
? (1) Specific values
A value in the range of valid values for a given point in time
? (2) *
All values in the range of valid values at a given point in time
Say "every ..."
? (3) Discrete value
#,#,#
? (4) Continuous value
#-#
? (5) in the specified time range, define the step size
/#: #即为步长
? Example: Echo command every 3 hours
0 */3 * * * centos/bin/echo "howdy!"
In general, the number of months and weeks usually do not appear at the same time, if all appear, indicate or the relationship, will be executed
@reboot run once after reboot: Indicates the next boot run
? @yearly 0 0 1 1 *
? @annually 0 0 1 1 *
? @monthly 0 0 1 * *
? @weekly 0 0 * 0
? @daily 0 0 * * *
? @hourly 0 * * * *
Planned tasks for the system:
/etc/crontab
/etc/cron.d/configuration file
/etc/cron.hourly/Script
/etc/cron.daily/Script
/etc/cron.weekly/Script
/etc/cron.monthly/Script
Linux processes and Scheduled tasks