Add timed tasks under Linux

Source: Internet
Author: User

Linux timed task files in/etc/crontab

Just open it straight vim/etc/crontab.

How to enter the command and time to execute in the crontab file. Each row in the file contains six fields, the first five of which are the time the specified command was executed, and the last field is the command to be executed.
Spaces or tabs are used to separate each field. The format is as follows:
Minute hour day-of-month month-of-year day-of-week commands
Legal value 00-59 00-23 01-31 01-12 0-6 (0 is Sunday) commands (represents the script to be executed)
In addition to the numbers there are several special symbols that are "*", "/" and "-", ",", * represent all the values within the range of the number, "/" for each meaning, "/" for each of the 5 units, "-" represents from a number to a number, "," separate several discrete numbers.

A few examples:
Every morning at 6.
0 6 * * echo "Good morning." >>/tmp/test.txt//Note simply Echo, no output is visible from the screen, because cron emails any output to root.

Every two hours
0 */2 * * echo "has a break now." >>/tmp/test.txt

11 o'clock to 8 a.m. every two hours and eight a.m..
0 23-7/2,8 * * * echo "a good Dream" >>/tmp/test.txt

Every month, number 4th and Monday to Sunday, three a.m., 11.
0 4 * 1-3 command line

January 1 morning, 4.
0 4 1 1 * command line Shell=/bin/bash path=/sbin:/bin:/usr/sbin:/usr/bin mailto=root//If an error occurs or there is data output, the data is sent to this account as an email home= /

Execute scripts within/etc/cron.hourly per hour
* * * * * Root run-parts/etc/cron.hourly
Execute scripts within/etc/cron.daily daily
4 * * * Root run-parts/etc/cron.daily

Execute scripts within/etc/cron.weekly every week
4 * * 0 root run-parts/etc/cron.weekly

Every month to execute scripts within the/etc/cron.monthly
4 1 * * Root run-parts/etc/cron.monthly

Note: "Run-parts" This parameter, if you remove this parameter, you can later write to run a script name, not the folder name.

Every day 4 o'clock in the afternoon, 5, 6 points of 5 min, min, min, min, min, min, when the execution of orders.
5,15,25,35,45,55 16,17,18 * * command

Every Monday, three, five 3:00 the system enters the maintenance state and restarts the system.
* * 1,3,5 shutdown-r +5

10 minutes per hour, 40 minutes execute the innd/bbslin command in the user directory:
10,40 * * * * Innd/bbslink

1 minutes per hour execute the bin/account command in the user directory:
1 * * * * bin/account

Execute two instructions (each instruction is delimited) below the user directory every day 3:20 A.M.:
3 * * * (/bin/rm-f expire.ls logins.bad;bin/expire$#@62;expire.1st)

Each year in January and April, 4th to 9th of 3:12 and 3:55 execute/bin/rm-f expire.1st This command, and add the results after mm.txt this file (mm.txt file is located in the user's own directory location).
12,55 3 4-9 1,4 */bin/rm-f expire.1st$#@62;$#@62;mm.txt

Add timed tasks under Linux

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.