The Python language--crontab writes logs to a file every day, in conjunction with a Python script implementation

Source: Internet
Author: User
Tags python script

First, the foregoing

There are a lot of ways that Python scripts can be written to log files on a daily basis in the actual work, and there are a number of methods to achieve this effect. This article chooses a way to realize, special will realize the detail to do the following to share, improper place please correct.

Second, the specific

1. The Python script needs to add logger output to each Python file.

As follows:

2. Add a background execution mechanism to the shell script.

Note:

1, Nohup is the key to this inside do not write the wrong format I just because written nohup .... >>file & This format led to the clear manual execution of the log output but into the scheduled task there is no log.

2, the software operating environment in this area such as ... /python must be written as an absolute path, even if the environment variable Lee is configured, because crontab cannot recognize environment variables.

3. crontab Scheduled Tasks

3 Days one execution.

In addition, do not mistakenly press Crontab-r when editing (delete all scheduled tasks) because CRONTAB-E is the editor E and R letters must have a mission to be careful not to ask me how to know. All Is tears ~ ~

The Python language--crontab writes logs to a file every day, in conjunction with a Python script implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.