File Search and Find tool:
Install file name or file properties to locate and locate the path to the files;
Locate: Fuzzy search tool;
Based on a dedicated database to find, but only if the database must exist beforehand, and need to be updated regularly;
Lookups are very fast, but the search accuracy is limited and limited to what is contained in the database;
It is possible to implement a manual update of the database under certain circumstances, requiring the use of the UpdateDB command;
/var/lib/mlocate/mlocate.db:locate查找的数据库文件; find:精确查找工具; 查找精度非常高,但速度比较慢; 在指定的位置通过文件名或其他文件的关键属性对文件进行遍历扫描; 注意:不建议对根目录进行find操作; 实时查找; 限制:使用find命令仅能完成当前用户有读和执行权限的目录的扫描查找;
Find command:
Find-search for files in a directory hierarchy
Find [path ...] [Expression]
Path: Find the path;
Default to the current working directory, you can also specify the specific path to find the directory;
Expression
OPTIONS:
TESTS: Search conditions;
Implementation of the criteria for this search, you can specify the file name, you can specify such as: the size of files, file types, file permissions and timestamps, etc.;
Actions: Handling actions;
A specified processing operation is performed for the found qualifying file, and the default value is to output the lookup results to standard output;
Search criteria: Search by file name:-name pattern: File name supports the use of globbing; (*,?, [],[^]) [[EMAIL PR Otected] ~]# find/etc/pass*/etc/passwd/etc/passwd--in Ame pattern: Ignore the difference in the case of the letter in the file name, while searching; support for using globbing;-samefile Name: Finds the path to other hard-link files based on the file name of the specified file; Based on the Ino of the file De number lookup:-inum N:-links N: Finds all files with a hard connection number of "n";-regex pattern:-ire Gex pattern: Search by file ownership:-user Uname-uid UID is based on user name and/or user ID To find all files owned by the owner of this user account;-group gname-gid GID is a group name and/or group ID to find all files belonging to this group of accounts; -nogroup: On the permission bit of ownership of the file, there is no group name that only shows the file belonging to the group ID;-nouser: On the permission bit of ownership of the file, there is no file with the master name showing only the master ID; Type:-type C:C represents a single-character descriptor for a file type, which includes: B: Block device C : Character device D: Catalog F: Normal file L: Symbolic link P: pipe s : Socket-xtype C: The search result of a symbolic link file requires a different selection of mates to be found, otherwise the original file being linked is searched; Find in days:-atime [+|-]n: Lookup based on access timestamp-ctime [+|-]n: Finding based on change timestamp -mtime [+|-]n: Lookup based on modified timestamp n:[n,n+1) +n:[n+1,+oo) -n:[now,n) to find in minutes:-amin [+|-]n:-cmin [+|-]n: -mmin [+|-]n: Search According to file size:-size [+|-]N[CWBKMG] n: (N-1,n] +n:[n,+oo)-n:[0,n-1] ~]# find/etc-size +2m logical operator combination preceding conditions for complex logic judgment: -A | -and: Logic and operation, the default is the logical operation, can be omitted;-O | -or: Logic or operation;-not |!: logical non-operation; Demogan law still in force; Search by permissions:-perm [/|-]mode mode: exact permission match, meaning to find files that must exactly match the specified permission bit;/mode: the right of any one of the permission bits In the limit, as long as there is a permission to satisfy the condition, that is, to match the success, it can be used as a search result;-mode: the permission of each permission bit must contain the specified permission bit, in order to satisfy the condition, the match succeeds, it is used as the search result; True take anti false false take reverse true all for true take anti any one false all for false Take the inverse of any one for the true processing action:-print: To output the matching results directly to the standard output, the default action,-ls: To display the results of the "ls-dils" command, which is the result of the execution of the Add-ls will show the details of the found results;-exec command {} \; -ok command {} \; For a matching search result, follow the commands command again, {} is a placeholder, meaning: The path information used to refer to each file in the Find command's lookup results; Note:-exec is non-interactive;-ok is interactive, many commands cannot be placed behind the pipe, because the pipeline is conveying pure string information, so the commands behind the pipeline generally must be commands to handle strings, and if the command placed after the pipe cannot handle the pure string, you can usually use the Xargs to convert it Parameters that can be processed by the command behind the pipeline; Example: # find-perm/222 | Xargs chmod a+w # chmod a+w $ (find-perm/222) # find-perm/222 {-exec|-ok} chmod a+w {} \; Find files on the current system that do not belong to the master or group, and have been visited in the last one months, and change their genus to root; Find/nouser? nogroup-atime-1-exec chown Root : root {} \;
Linux Task Scheduler:
At some point in the future, let the system automatically trigger the execution of a list or script of our pre-written commands, so that the task can be completed on time, even if the user is not on the computer;
Prerequisites: 1. The accuracy of the time; 2. Applications that support task scheduling; ATD: Perform a scheduled task at some point in the future; Crond: Perform scheduled tasks periodically at some point in the future; note: The output of all action commands executed in the scheduled task , such results are sent by mail to the specified user's mailbox; local e-mail service: SMTP: Simple Mail Transfer Protocol, TCP/25; Mail [-S SUBJECT] username[@DOMAINNAME]/var/spool/mail For each system user, the ATD task scheduling process is able to identify and complete scheduled tasks with at command and Batch command customization; at command: at [option] Timespec timespec:1. hh:mm [Yyyy-mm-dd] 2.noon, midnight, teatime 3.tomorrow 4.now+ #UNIT unit:m Inutes, hours, days, or weeks the scheduled tasks defined by at is in a particular task queue; The default at is only one task queue is enabled, identified by the letter "A", and the queue name usually uses a single letter; The common use of the AT command: at [-Q queue_name] Time: Define scheduled Tasks, Ctrl+d commit after entering a task, ATQ or at-l View the list of scheduled tasks not yet executed in all task queues; ATRM job_id or at-d job_id to revoke a scheduled task for a specified task identifier that has not been performed in the task queue; At-f/path/to/some_file time At-c job_id: View the specific contents of a specified scheduled task; Batch command: Similar to the AT command, is a one-time definition of a scheduled task, except that the batch command defines a scheduled task without specifying the execution times, but rather the system automatically chooses to finish the idle time Crond Task scheduling process: ability to identify and cycleThe execution of the crontab command is customized to the scheduled tasks, Cronie packages are required, usually installed by default in the CentOS system, and the scheduled tasks defined by Crontab are divided into two categories: System tasks: Global tasks, and generally use/etc/c Rontab file definition; Common format for/etc/crontab files: * * * * * * user-name command to be executed Minutes hours Day Month Week NOTE: * * * * *: Define the time for periodic execution of scheduled tasks; User-name: User account running the following command; command to be executed: The execution body of the scheduled task; In order to ensure that the task executes correctly, the commands suggest using absolute paths; User tasks: individual tasks; usually stored in/VAR/SPOOL/CR om/in the file corresponding to the user name; The format of such a file: * * * * * command to be executed minutes hours days Month-week time notation: 1. A specific time: all valid values in the range of valid values for a given point in time, 0 3 4 9 5 2. Wildcard Time: "*", which means "every ..." 3. Discrete point in time: 0 8,20 * * 1,2,4,5 4. Continuous time period: 0-10 8-12 * * 5. Stepping Time: */3 * * * * */9 * * * *: Can not be implemented every 9 minutes, so by default, the step length should be divisible by 60 number; Note: the Smallest The time unit is minutes, if you plan to use a few seconds for less than a minute toExecution cycle, you must rely on other mechanisms, such as: Write shell script; user Recurring task customization: crontab command: crontab-maintains crontab files for individual users crontab [-u user] File crontab [-u user] [-l |-r |-e] [-i]-u user: The option that the Superuser uses to set or edit recurring tasks for himself or another user; -L: View all the list of scheduled tasks that have been defined;-e: Use the VI Editor to edit temporary crontab files;-r: Remove all scheduled tasks; recommended caution;-I: When using the-r option , capable of interactive deletion;
Find command usage and Linux task scheduling