Linux regularly performs tasks. Implementation Tutorial

  
 

Today I watched a video about server performance testing. The video mentioned a Linux crontab command, a strange command, and then read the information, wrote a small demo to summarize this crontab-related knowledge. For me, this is another new knowledge point, and it is improving every day.

Go to the /etc directory and look at the Ubuntu /etc directory to see, we all know that the /etc directory is mainly used to store the configuration files in the system, basically all configuration files can be here turn up. Run the following command to see:

ls /etc/cron* This command will list all files and folders starting with cron in the /etc directory. You can see that there are mainly the following folders:

/etc/cron.hourly This stores the scripts that need to be run every hour. /etc/cron.daily This stores the scripts that need to be run every day. /etc/cron.weekly Here is the script that needs to be run every week /etc/cron.monthly. Here is the script /etc/cron.d that needs to be run every month. If it is not running by hour, nor by day, week and month, put it. In this folder, we can put the scripts we need to run regularly into the corresponding folder, and the system will run the corresponding scripts at regular intervals. So how does the system do it?

In the /etc directory, there is also a crontab file. The contents of this file are as follows:

# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to Run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.

SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# mh dom mon dow user command17 * * * * root cd /&& run-parts --report /etc/cron.hourly25 6 * * * root test -x /usr/sbin/anacron

Copyright © Windows knowledge All Rights Reserved