In linux, a process is automatically executed at a scheduled time.

Source: Internet
Author: User
Article Title: Scheduled Automatic Execution of a process in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Recently, I am studying nutch and want it to automatically crawl the content of our school's website every day. Cron is the tool to solve this problem.

Cron is a scheduled execution tool in linux. It can be used without manual intervention. You can run the following command to manually enable or disable the task:

/Sbin/service crond start the service

/Sbin/service crond stop close the service

/Sbin/service crond restart the service

/Sbin/service crond reload the service

Cron:

Minute hour, day month week [user name] command

Note:

The first section should be defined as minute, which indicates the minute of every hour for execution. The value range is from 0 to 59.

The second part should be defined as hour, which indicates execution from hour to hour. The value range is from 0 to 23.

The third paragraph should be defined as: date, which indicates execution from the day of each month, range from 1-31

The fourth part should be defined as month, which indicates the number of months of the year to be executed, ranging from 1 to 12.

The fifth part should be defined as Week, which indicates the day of the week for execution, ranging from 0 to 6, where 0 indicates Sunday.

The user name should be defined in each section, that is, the user in which the execution program is to be executed, which can be omitted;

Section 7 should define the commands and parameters to be executed.

In the system, the/etc directory contains cron. daily, cron. hourly, cron. monthly, cron. weekly file directory. You only need to add a shell file in the corresponding directory to automatically execute it regularly.

For example, if you want to enable automatic crawling of the content at 09:00 every morning, you can:

[Root @ localhost cron. daily] # touch autonutch. sh

[Root @ localhost cron. daily] # chmod 755 autonutch. sh/* change the access permission of autonutch. sh */

[Root @ localhost cron. daily] # echo "/home/sunny/nutch/bin/nutch crawl urls-dir crawl"> autonutch. sh

[Root @ localhost cron. daily] # more autonutch. sh

/Home/sunny/nutch/bin/nutch crawl urls-dir crawl

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.