Centos7 Linux tries to use Crontab

Source: Internet
Author: User

First, install the crontab

[email protected] ~]# Yum install Vixie-cron
[email protected] ~]# Yum install Crontabs

Description
Vixie-cron package is the main program of Cron;
The Crontabs package is a program used to install, uninstall, or list tables used to drive the cron daemon.
Cron is a built-in service for Linux, but it does not automatically get up, and you can start and shut down this service in the following ways:
/sbin/service Crond Start//Startup service
/sbin/service Crond stop//Shut down service
/sbin/service crond Restart//Restart service
/sbin/service Crond Reload//Reload Configuration

View crontab Service Status: Crond status

Manually Start crontab services: Service Crond start

Reference: http://os.51cto.com/art/201004/192442.htm

Ii. Use of tasks

1. Direct distribution

#crontab-E

And then come out with an editable file: You can do this by setting the time

For example, the task output date is executed once per hour to the/home/mydatetest file

0 * * * * Date >>/home/mydatetest

Execute once per minute

* * * * * Date >>/home/mydatetest

Here's a complicated notation.

Edit the scheduled task under root crontab-U Root-e appends a string to a text at 6 o ' Day in the morning. 0 6* * * echo"Good morning.">>/tmp/Test.txt appends a string to a text every two hours. 0*/2* * * echo"There is a break now .">>/tmp/test.txt 11 o'clock to 8 a.m., every two hours, eight a.m. .0  at-7/2,8* * * echo"a good dream:)">>/tmp/Test.txt, 4th per month and Monday to Sunday, three a.m. 11 .0  One 4*1-3Command line1 month 1st Morning 4 o ' Day0 4 1 1*command line every hour of the month of the first0Minutes to execute/bin/ls0* * * * */bin/ls in AEvery morning in the month6Point to APoint, every -Minutes to execute/usr/bin/Backup*/ - 6- A* A*/usr/bin/backup Monday to Friday every afternoon5:xxsend a letter to Alex_mail_name:0  -* *1-5Mail-s"Hi"Alex_mail_name </tmp/Maildata Midnight every day of the month0Point -Score of2Point -Score of4Point -Points .... Perform echo"haha" - 0- at/2* * * echo"haha"11 o'clock to 8 a.m., every two hours, 8 a.m., Show time .0  at-7/2,8* * * Date

2. Through the *.sh file

2.1 Establish *.sh to set its permissions to 744:chmod 744 mytask.sh

2.2 Ibid. method Direct * * * * * mytask.sh can be

3. Delete All Tasks Crontab-r

Centos7 Linux tries to use Crontab

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.