Many times we need a server to run a command at a certain time, such as executing a script.
Then we can install "crontabs" this software.
It is installed by default on my CentOS server and is not installed to run:
Yum Install vixie-cronyum install Crontabs
Vixie-cron package is the main program of Cron;
The Crontabs package is a program used to install, uninstall, or list tables used to drive the cron daemon.
The commands for starting the service, shutting down the service, restarting the service, and re-loading the configuration are as follows:
// Start the service // Close Service // Restart Service // Reload Configuration
View the current service status for Crontab: Service Crond Status
After you start the Crontabs service, you can add the same tasks with CRONTAB-E.
Of course also can edit/etc/crontab this file also line.
The format written under the file is: * * * * * ' task '
such as the following:
The first ' * ' is a minute. (0-59)
The second ' * ' is an hour. (0-23)
The third ' * ' is the day. (1-31)
The fourth ' * ' is the month. (1-12)
The fifth ' * ' is a week. (0-6 of course 0 and 7 can represent Sunday)
Here are a few examples.
* * * * * ls//execute the LS command once every minute7* * * * ls//The LS command is executed 7 minutes per hour*/7* * * * ls//execute a LS command every 7 minutes7 7* * * ls//7 points per day, 7 minutes. Execute the LS command7 7 7* * ls//every month, 7th, 7, 7. Execute the LS command once7 7 7 7/8* ls//every year, July and August, 7th, 7, 7, execute the LS command .7 7* *0Ls//every Sunday, 7 points, 7 minutes. Execute the LS command
At first I used this to execute the PYTHON3 program, but found that the. py suffix is not an executable file, what should I do?
Find a method on the Internet, you can write a shell script to run the Python3 program, so you can schedule to execute the PYTHON3 program.
As shown below:
That's perfect.
Execute scripts using crontab timer under Linux