Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the symbols commonly used in linux cron planning tasks

Shulou Source: shulou.com Published: 2022-06-03 10:56:57 10月31日 Update

This article introduces the knowledge of "what are the symbols commonly used in linux cron planning tasks". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

[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

-l (list user's crontab) to view the work of crontab

-r (delete user's crontab) delete all crontab tasks

-I (prompt before deleting user's crontab)

-s (selinux context)

By default, any user who is not included in / etc/cron.deny can execute "crontab-e" to edit their own routine commands.

The meaning of the representative

Minute

Hour

Date

Month

Zhou

Numeric range

0-59

0-23

1-31

1-12

0-7

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

Auxiliary character

Special character

Representative meaning

* (asterisk)

It means to accept it at any time.

, (comma)

Means to divide a period of time, if you want to perform 2:00 and 4: 00:00

0 2 ~ 4 * command

The time parameter has five columns, and the second column is 2Jing, which represents 2:00 and 4:00.

-(minus sign)

Represents a range of time, such as every 10 minutes an hour between 7 and 10:00

Job: 10 7-10 * command

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

/ n (slash)

That n represents a number, which means an interval of n units, for example, every 5 minutes.

Then: * / 5 * command

It can also be written as 0-59 stroke 5 with the same meaning.

System task planning

[root@wx-a ~] # cat / etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# For details see 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

Crontab-e is designed for the user's cron.

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

Standard output (stout): use > or > for code 1

Standard error output (stderr): code 2 uses 2 > or 2 >

Black hole / dev/null

Error output 2 > & 1

Cron allows scheduled tasks not to be 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 to the black hole.

[root@wx-a ~] # crontab-l

* / 1 * echo "hello"

[root@wx-a ~] # crontab-l

* / 1 * echo "hello" > / dev/null 2 > & 1 is output to the black hole.

For other help, check out 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

This is the end of the content of "what are the symbols commonly used in linux cron planning tasks". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Representative output task content meaning number black hole work common use symbol code character hour work content situation meaning time more standard user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB vpn Docker Shulou Tech Info