1. Python automatically runs at startup Suppose the Python self-starting script is sudo vim /etc/rc.local If you don't have Edit the command to start the script above exit 0 /usr/bin/python3 /home/selfcs/auto.py > /home/selfcs/auto.log Finally, restart Linux and the script will run automatically and print logs. 2. Start the Python script regularly Edit the following file with root privileges sudo vim /etc/crontab Add the following command at the end of the file 2 * * * * root /usr/bin/python3 /home/selfcs/auto.py > /home/selfcs/auto.log The above code means that the script will be executed every two minutes and the log will be printed. 3. Crontab Writing Explanation Basic format * * * * * user command Time-sharing, daily, monthly and weekly user commands 3.1 Example 1: Execute once every minute * * * * * user command 2. Execute every 2 hours * */2 * * * user command (/ indicates frequency) 3. Execute once every day at 8:30 30 8 * * * user command 4. Execute once at 30 and 50 minutes of every hour 30,50 * * * * user command (, indicates parallel) 5. Execute once at 8:30 on the 3rd to 6th of each month 30 8 3-6 * * user command (- indicates range) 6. Execute once every Monday at 8:30 30 8 * * 1 user command (the range of the weekday is 0-7, 0 and 7 represent Sunday) Summarize The above is the detailed steps for the self-start and scheduled startup of Python scripts under Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to use a field in one table to update a field in another table in MySQL
>>: JS implements a simple brick-breaking pinball game
After minimizing the installation of Python8, I i...
Situation description: The database was started a...
Recently, new projects have used springcloud and ...
[Looking at all the migration files on the Intern...
How to use CSS to control the arc movement of ele...
background There is a requirement in the project ...
When you need to create an email in a shell scrip...
When using the docker-maven-plugin plug-in, Maven...
1. I searched for a long time on the Internet but...
Table of contents 01 CMD 02 ENTRYPOINT 03 WORKDIR...
Preface If you want to count the source of websit...
If the words in the sql statement conflict with t...
MySql Index Index advantages 1. You can ensure th...
NodeJS copies the files: Generally, the copy oper...
All websites, whether official, e-commerce, socia...