In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Most people do not understand the knowledge points of this article, "how to write a regular script for python under Linux", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to write a script for python timing under Linux".
1. Python starts up and runs automatically
If the Python self-startup script is auto.py. Then edit the following files with root privileges:
Sudo vim / etc/rc.local
❝
If there is no rc.local, please read this article.
The command to edit the startup script on exit 0
/ usr/bin/python3 / home/selfcs/auto.py > / home/selfcs/auto.log
Finally, restart Linux, and the script can run and print the log automatically.
Second, let the Python script start regularly
Edit the following files with root permissions
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 is executed every two minutes and the log is printed.
III. Crontab compiles explanations
Basic format
* user command time-sharing, day, month and week user command
3.1 give an example
1. Execute once every minute
* user command
2. Execute every 2 hours
* * / 2 * user command (/ represents frequency)
3. It is executed at 8:30 every day.
30 8 * user command
4. 30 minutes and 50 minutes per hour are executed respectively.
3050 * user command (, which means juxtaposition)
5. It is executed at 8:30 from the 3rd to the 6th of each month.
30 8 3-6 * * user command (- indicates range)
6. It is executed every Monday at 8:30
308 * * 1 user command (the range of weeks is 0-7 user command 0 and 7 represent Sundays). The above is about "how to write a regular script for python under Linux". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 256
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.