“This is the 25th day of my participation in the August Gwen Challenge.

The vast sea of millions, thank you for this second you see here. Hope my article is helpful to you!

May you keep your love and go to the mountains and seas in the coming days!

Linux advanced commands

Yesterday we have made the Linux command learning process management and know how to view all the processes in Linux, and kill the process can be a closed function, we can also see some of the Linux memory consumption and other operations, we are learning more than that, of course, our pipe for Linux today, Filter and configure scheduled task learning! Let ‘s GO!

Linux filter filter

grep

Grep can be a powerful text search tool (file content filter) that searches text using strings and prints out matching lines and line numbers.

Can also do filter with pipeline operator |

Parameter Description:

  • N: Searches for the string content in a specified file
  • V: displays mismatched rows
  • I: Search regardless of case

Demo search:

Pipe |

The pipe character is usually used with the grep command to filter.

Demo pipe with grep:

Linux crontab scheduled task

Task scheduling: refers to a specific command or program executed by the system at a certain time.

Task scheduling classification:

  1. System work: Some important work must be performed over and over again. Such as virus scanning
2. Individual user work: Individual users may want to perform certain programs, such as backups of the mysql databaseCopy the code

Crontab Configures scheduled tasks.

Command parameters:

  • L: Displays all scheduled task machines of the current user
  • E: Use vim to edit the scheduled task of the current user, one in a row
  • R: Deletes the scheduled task of the current user

Presentation:

Configuring a Scheduled Task

Format: minute, day, month, week command

The crontab timing command can be executed only in minutes, not in milliseconds. If you need to run the command in milliseconds, use Java

Description: A scheduled task is a command executed at a specified time

  • “Minute” : indicates the minute. The value is an integer ranging from 0 to 59
  • Hour: indicates the hour. The value is an integer ranging from 0 to 23
  • Day: indicates the day. The value is an integer ranging from 1 to 31
  • Month: indicates the month, any integer from 0112
  • Week: indicates a week. The value is an integer ranging from 0 to 7. 0 or 7 indicates Sunday, and 1-6 indicates Monday to Saturday
  • Command: indicates the command to be executed

Special characters:

Asterisk * : represents all possible values.

Comma, : Comma separated values to specify a point in time

Short bar – : indicates an integer range

Forward slash / : indicates the interval frequency of a specified time

Eg:

* * * * * command --> run 30 21 * * * command --> run 3,15 * * * * command --> run 6,12, 3-4 * * * every third and 15th minute of every hour */3 * * * * command --> Run every three minutes from 3am to 4am on the 6th and 12th minuteCopy the code

Run the following command to output the current system time:

date
Copy the code

Example: Print the current system time to the /root/mydate.log file every minute

Implementation steps:

  1. Run the crontab -e command to enter the scheduled task editor for editing the current user

  2. Write a scheduled task command

  3. >> stands for append output

    * * * * * date >> /root/mydate.log
    Copy the code
  4. > represents override output

  5. Watch the run to see if it prints every minute.

conclusion

I believe that you are on the Linux system of powerful filtering filtering function and configuration of the function of the scheduled task have a certain understanding, looking forward to waiting for the next chapter of Linux in the advanced command of some service management commands to learn it!

Of course, there are more commands to watch next time! Welcome to the next chapter!

Let’s refuel together, too! I am not just, if there is any missing, wrong place, also welcome you to criticize in the comments of talent leaders! Of course, if this article is sure to help you a little, please kindly and lovely talent leaders to give a thumb-up, favorites, one key three even, thank you very much!

Here, the world is closed for today, good night! Although this article is over, I am still here, never finished. I will try to keep writing articles. The coming days are long, why fear the car yao ma slow!

Thank you all for seeing this! May you live up to your youth and have no regrets!