. Neter Linux Series V: crontab Process management and network status monitoring using detailed understanding and Linux

Source: Internet
Author: User
Tags set time

First, crontab use detailed
    • Overview: Task scheduling: Refers to a particular command or program that the system executes at a certain time.

Task Scheduling Classification:

(1) System work: Some important work must be carried out in a cycle.

(2) Individual users work: Individual users may want to execute certain programs.

Usage Scenarios: Database backup problems, either manually backed up, and cannot be backed up during the day. Generally back up the database when you often need to shut down the database, because the backup, write again easily caused the database backup, hot backup MySQL also support, but generally use cold backup. At this point, you need to use task scheduling.

When I'm not using crontab, I want to store the current time in a file.

is not very simple, well, when explaining how to use crontab, we first take a look at the picture (thanks to this predecessor's diagram), because this picture can handle everything:

  

  

If you want to know more, you can refer to this predecessor's article: http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html

    • How to use crontab (scheduling a task)

(1) Setup task: CRONTAB-E

    

    

Encounter this problem do not panic, this problem I find a lot of solutions are not, and finally a foreigner article saved me. First, execute the following command:

    

Choose a good crontab editor (here I choose 3) to enter. Then enter the command:

    

If this interface appears, it has already succeeded!

    

As with the VI editor, enter the following command: Records the current time per minute and writes to the Mydate2 file.

    

After writing the input: Wq can be saved, if the following message appears, the above scheduling task has been working:

    

If you want to see what scheduling tasks the root user has, you can use: Crontab-u root-l to view them.

    

(2) Perform date >/home/gz/mydate at a certain time (per minute) (This command has already been mentioned, if you forget to go back to review)

    

OK, you can try it, if you encounter problems, you can put it in the comment area, I will help you to see.

Note: The crontab is not accurate to the second, only accurate to the minute.

    • Scheduling Multiple tasks

    1) write directly in the CRONTAB-E. (Not recommended)

You can try it, I won't try it here.

2) All tasks can be written to an executable file (Shell programming) (recommended)

First write: mytask.sh (note: The file suffix for Shell programming is. SH)

    

We found no: This file is not executable permissions, forget to go to the previous review, so next we want to change the permissions of the file.

    

Then write: crontab

    

    

Save and exit:

    

This means that the command inside the shell script is executed every minute.

Detection: Whether the mydate3 is under the root directory.

    

    

    

    • How to terminate a task

Command: conrtab–r: Terminates task scheduling. (It is recommended to use caution, preferably commented out)

Well, Crontab said here is the end, I hope to help you, into the next topic to explain.

    

Second, the process management of Linux

(1) Overview:

Process: A process is a program being executed

Threads: (1) a lightweight process. (2) The process has a separate address space, and the thread does not. (3) A thread cannot exist independently, it is created by the process. (fork) Thread. (4) Relatively speaking, the thread consumes CPU, and the memory is less than the process.

(2) in Linux, each executed program is called a process. Each process is assigned an ID number, and each process can exist in two ways. Front desk and backstage, the so-called foreground process is the user's current screen can be operated. Background processes are actually in action, but because of processes that are not visible on the screen, they are usually performed in the background, and the services of the general system exist in the form of a background process and are resident in the system. It was not until the shutdown was over.

How do I see what is going on in the current system, and what is the status of their execution?

Command: Ps-aux | More

  

Explanation: User: The name of the process; PID: Process ID;%CPU: Process-occupied CPU;%MEM: process-occupied memory; VSZ: virtual memory;

RSS: physical memory; The PID 1 is the parent process for all processes.

How to terminate a process: You can consider stopping a process if it is half the time it needs to be stopped, or if a large system resource has been eliminated. Use the KILL command to complete this task.

Command: Kill 3051 (This command is a little gentle, not necessarily killing the process (bash))

If you want to force kill, you can use: Kill-9 3051 (try to be a little kicked out of the group feeling (#^.^#))

Add:

Kill-9 3051: Because some processes capture certain signals, the process can send messages with "9" if it is not able to end directly.

Killall: All child processes under the process will be killed.

Third, the process status monitoring of Linux

Overview: Top is very similar to the PS command. They are all used to show the process being executed. The biggest difference between top and PS is that top performs a period of time to update a running process.

Command: Top

If you want to back out: press: Q or CTRL + C

Command: top-d 10: Specifies the system update process time is 10 seconds

Command: Specify to monitor some users

Top: Enter this command and press ENTER to see the process being executed. then enter the small u: then enter "U" return, and then enter the user name, you can.

This means: I want to monitor GZ users.

Command: terminate the corresponding process

Top: Enter this command and press ENTER to see the process being executed. K: Then enter the "K" carriage return and enter the process ID number to end.

Iv. Linux monitoring network status

Overview: This command can be used to monitor those IP links to Linux, if it is illegal users, you can kill these IP.

Use: Displays the network statistics command netstat, which is used to display the current network situation of the entire system. For example, current connections, packet-passing data, or routing table content. This command can be used directly by typing.

Command: Netstat-an | More

Command: NETSTAT-ANP | More show the corresponding process ID

Show Packet History command: ROUTE

Command: traceroute

Install first: sudo apt-get traceroute

Available in Windows: Tracert www.baidu.com

Five, set the system time

(1) Display system time

Command: Date

(2) Set time

Command: Date mmddhhmmccyy. SS: means: The day and day of the month are divided annually. seconds.

I'm not going to show it.

(3) View calendar

OK, today is about here, the evening to continue to update the last article, I think you can, I hope the recommendation ha ~ Your recommendation is my motivation.

Guo Yan

Source: http://www.cnblogs.com/runningsmallguo/

The copyright of this article is owned by the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to give the original link.

. Neter Linux Series V: crontab Process management and network status monitoring using detailed understanding and Linux

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.