Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Linux deploys python crawler scripts and sets scheduled tasks

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how Linux deploys python crawler scripts and sets scheduled tasks. I hope you will get something after reading this article. Let's discuss it together.

The implementation steps are as follows:

1. Install pip (python2.6 comes with the operating system and can be used directly, but without pip)

# download pip installation package wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb"-- no-check-certificate# extract installation package and install tar-xzvf pip-1.5.4.tar.gzcd pip-1.5.4python setup.py install

two。 Install third-party libraries with pip

Pip install PyGreSQL==5.0.3pip install requests==2.18.3

3. Set up scheduled tasks

# enable scheduled task service service crond start# to view scheduled task service status service crond status# open scheduled task editing window crontab-e # add two scheduled tasks, that is, execute each day at 00:00 and 12:20 And write to the log 00 * / usr/bin/python / home/longrise/psrd/collect.py > / home/longrise/psrd/collect.log 2 > & 1 & 20 12 * / usr/bin/python / home/longrise/psrd/collect.py > / home/longrise/psrd/collect.log 2 > & 1 & scheduled task syntax as follows: # For details see man 4 crontabs# Example of job definition:#.- -minute (0-59) # |.-hour (0-23) # | |.-day of month (1-31) # |.-month (1-12) OR jan Feb,mar,apr. # |.-day of week (0-6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | # * user-name command to be executed finished reading this article I believe you have a certain understanding of "Linux how to deploy python crawler scripts and set up scheduled tasks". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report