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