Talking about: Common symbol summary of Linux cron program task _linux Shell

Source: Internet
Author: User

[Root@wx-a ~]# 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) deletes all crontab tasks
-I (Prompt before deleting user ' s crontab)
-S (selinux context)

By default, any user who is not included in the/etc/cron.deny can perform "crontab–e" to edit his or her routine commands.

The 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)

It means to be accepted at all times,

, (comma)

Represents the meaning of the split period, 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, and 4 represents 2:00 and 4:00

-(minus sign)

Represents a period of time, for example, 10 minutes per hour between 7 and 10.

Job: 7-10 * * * command

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

/n (Slash)

That n represents the number, that 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 Schedule

[Root@wx-a ~]# Cat/etc/crontab
Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
home=/
# for details, man 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

The CRONTAB-E is designed for users ' cron.

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

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

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

Black Hole/dev/null

Error Output 2>&1

Cron lets scheduled tasks not output on screen using >/dev/null 2>&1

[Root@wx-a ~]# Crontab-l
*/1 * * * echo "Hello" >>/tmp/test.txt
[Root@wx-a ~]# Cat/tmp/test.txt
Hello
[Root@wx-a ~]# Cat/tmp/test.txt
Hello
Hello

Let the output go inside the black hole.

[Root@wx-a ~]# Crontab-l
*/1 * * * * echo "Hello"
[Root@wx-a ~]# Crontab-l
*/1 * * * * echo "Hello" >/dev/null 2>&1 output to black hole

Other help is available to view man cron or man crontab

PS:OCSNG Linux Client Installation

Aptitude-y install gcc automake autoconf libtool make
aptitude-y install Dmidecode Libxml-simple-perl-libcompress -zlib-perl libnet-ip-perl libwww-perl libdigest-md5-perl libnet-ssleay-perl
aptitude-y Install Libcrypt-ssleay-perl libnet-snmp-perl Libproc-pid-file-perl Libproc-daemon-perl net-tools Libsys-syslog-perl Pciutils smartmontools read-edid nmap
Tar–xvzf ocsinventory-agent-2.0.x.tar.gz
CD ocsinventory-agent-2.0.x
Env perl_autoinstall=1 PERL makefile.pl
make
make install

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.