Execute the shell script function periodically through Linux crontab __linux

Source: Internet
Author: User
Paste:

http://blog.csdn.net/allenlinrui/article/details/7490206


With Crontab you can execute a shell script or a series of Linux commands at a specified time. For example, the system administrator schedules a backup task to run every day

Getting Started

# crontab–e

This allows you to open a personal crontab profile in edit mode, and then join this line:
0 0 * * */home/linrui/xxxxxxxx.sh

This will run the specified. sh file in the wee hours of the day.


Description of Cron items

The following is the format of the crontab file:

{minute} {Hour} {Day-of-month} {Month} {Day-of-week} {Full-path-to-shell-script}
O minute: Interval is 0–59
O Hour: Interval is 0–23
O Day-of-month: Interval is 0–31
O Month: The interval is 1–12. 1 is January. 12 is December.
o Day-of-week: The interval is range 0–7. Sunday can be 0 or 7.


Crontab Sample

1. Run at 00:01

1 0 * * */home/linrui/xxxx.sh

2. Backup jobs are performed every weekday 11:59.

1,2,3,4,5/HOME/LINRUI/XXXX.SH * * * *

Or the following wording:

1-5 * * * */home/linrui/xxxx.sh

3. Run one command per minute

*/1 * * * */home/linrui/xxxx.sh

4.1th # 14:10 per month run

1 * */home/linrui/xxxx.sh


options for the crontab command

The following are valid options for crontab:

Crontab–e: Modify the crontab file. If the file does not exist, it is created automatically.
Crontab–l: Displays the crontab file.
Crontab-r: Deletes the crontab file.
Crontab-ir: Remind users before deleting crontab files.

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.