Summary of common symbols for Linux cron scheduling tasks

Source: Internet
Author: User

[Email protected] ~]# crontab--help

Crontab:invalid option--'-'

Crontab:usage error:unrecognized option

Usage:crontab [-u user] File

crontab [-u user] [-e |-l |-r]

(default operation is replace, per 1003.2)

-E (Edit user ' s crontab) editing crontab work content

-L (list user ' s crontab) view crontab work content

-R (Delete user ' s crontab) Delete all crontab tasks

-I (Prompt before deleting user ' s crontab)

-S (selinux context)

By default, any user can perform "crontab–e" to edit their own routine commands as long as they are not included in the/etc/cron.deny.

Meaning of the representative

Minutes

Hours

Date

Month

Week

Number Range

0-59

0-23

1-31

1-12

0-7

When the number of weeks is 0-7, it means "Sunday".

Auxiliary characters

Special characters

Representative meaning

* (asterisk)

Mean to accept at any moment,

, (comma)

Represents the meaning of the split window, if you want to perform 2:00 and 4:00,

0 2,4 * * command

The time parameter has five columns, the second column is 2, 4 means 2:00 and 4:00

-(minus)

Represents a period of time, such as 10 minutes per hour between 7 and 10 points

Work: 7-10 * * command

The second column becomes 7-10 for 7 8 9 10

/n (Slash)

That n represents the number, which is the meaning of every n unit interval, for example, every 5 minutes,

Then: */5 * * * * command

Can also be written as 0-59/5 meaning the same

System Task Scheduler

[Email protected] ~]# Cat/etc/crontab

Shell=/bin/bash

Path=/sbin:/bin:/usr/sbin:/usr/bin

Mailto=root

home=/

# for details see Mans 4 Crontabs

# Example of Job definition:

#.----------------Minute (0-59)

# |.-------------Hour (0-23)

# | |.----------DAY of Month (1-31)

# | | |.-------month (1-12) OR jan,feb,mar,apr ...

# | | | |.----DAY of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * * user-name command to be executed

CRONTAB-E is designed for users ' cron.

Basically cron the minimum detection limit for this service is "minutes", so cron reads the contents of/etc/crontab and/var/spool/cron data once every minute.

Standard output (Stout): Code 1 using > or >>

Standard error Output (STDERR): Code 2 using 2> or 2>>

Black Hole/dev/null

Error Output 2>&1

Cron makes scheduled tasks out of the screen output with >/dev/null 2>&1

[Email protected] ~]# crontab-l

*/1 * * * * echo "Hello" >>/tmp/test.txt

[Email protected] ~]# Cat/tmp/test.txt

Hello

[Email protected] ~]# Cat/tmp/test.txt

Hello

Hello

Let the output go inside the black hole.

[Email protected] ~]# crontab-l

*/1 * * * * echo "Hello"

[Email protected] ~]# crontab-l

*/1 * * * * echo "Hello" >/dev/null 2>&1 output to black hole

Other help can be seen in man cron or man crontab

This article is from the "Little Rookie" blog, please be sure to keep this source http://xiaocainiaox.blog.51cto.com/4484443/1701975

Summary of common symbols for Linux cron scheduling tasks

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.