In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
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 examples 1. Execute once per 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
30 8 * 1 user command (the range of weeks is 0-7. 0 and 7 represent Sundays)
Summary
The above is the detailed steps of self-startup and timing startup of Python script under Linux introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!
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: 0
*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.