CentOS timed Python script execution

Source: Internet
Author: User

Linux is actually a timed task . Old can't remember parameters, this time write down, save the old Baidu. This article does not have the technical content, please everybody not to spit the trough.

================================================================

Execute the/opt/aa.py file with Python 4:00:01 every day.

To edit a timed task:

#crontab-E

Join:

0 4 * * * python/opt/aa.py

Save and exit.

================================================================

crontab command format:

* * * * * command
M H d M d command

M: Cents (0-59)
H: Hours (0-23)
D: Day (1-31)
M: Month (1-12)
D: Week (0-6) 0 for Sunday


* Represents a number in the range of values
/on behalf of "every"
-Represents a number to a number
, which represents a discrete value (list of values)

Example:

Execution per minute:

* * * * * * date>>/opt/test.log

Equivalent

*/1 * * * * date>>/opt/test.log

Note that every minute means that the 1th second of every minute begins to execute.

Open a Test.log file and you'll find the result: Sat Oct 14:25:01 CST 2013

Execute every 4 hours:

* */4 * * * date>>/opt/test.log

Executed every Sunday:

* * * * 0 Date>>/opt/test.log

Executed every Saturday and Sunday:

* * * * * 6,0 Date>>/opt/test.log

The first 5 minutes per hour is performed:

5 * * * * date>>/opt/test.log

Very simple, just remember the position and the meaning of the line.

Reference address

CentOS timed Python script execution

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.