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 to execute a process regularly and automatically under linux

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

Share

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

This article is about how to automatically execute a process on a regular basis under linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Cron is a timing execution tool under linux, which can work without human intervention. You can turn the task on or off manually with the following command:

/ sbin/service crond start start the service

/ sbin/service crond stop shuts down service

/ sbin/service crond restart restart the service

/ sbin/service crond reload reload service

The writing format of cron configuration scheduled tasks:

Minute hour, day, month, week [user name] command

Description:

The * paragraph should be defined as a minute, which represents the minute on which each hour is executed. The range is from 0 to 59

The second paragraph should be defined as: hours, indicating the hour from which to execute, with a range of 0-23

The third paragraph should be defined as the date, indicating the day from which it will be executed, ranging from 1 to 31.

The fourth paragraph should be defined as: month, which indicates the month of the year, ranging from 1 to 12.

The fifth paragraph should be defined as: week, which represents the day on which the week is executed, ranging from 0 to 6, where 0 means Sunday.

What should be defined in every six paragraphs is the user name, that is, the user through which the program is executed, which can generally be omitted.

The seventh paragraph should be defined as the commands and parameters executed.

In the system, under the / etc directory, there is a cron.daily,cron.hourly,cron.monthly,cron.weekly file directory, we only need to add the written shell file under the corresponding directory to execute automatically.

If I want nutch to start fetching automatically at 09:00 every morning, I can do this:

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

[root@localhost cron.daily] # chmod 755 autonutch.sh / * change the access to 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

Thank you for reading! This is the end of this article on "how to execute a process automatically under linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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