Ubuntu16 installing cron and using

Source: Internet
Author: User

Https://www.cnblogs.com/intval/p/5763929.html

sudo apt-get install cron

Start cron

sudo service cron start

View all cron services on this computer

Ls-l/ETC/INIT.D

Edit a file: User name +cron

*/2 * * * * Date >>/home/postgres/time.log

Enter the above content,

Then: Wq

Then service cron Restart

In a minute, the current time is printed to the Time.log

# m H Dom Mon Dow command

M min 0-59

H hours 0-23

Dow Day 1-31

Mon month 1-12

Dow Week 1-6 0 indicates Sunday

command is the order to execute.

Example 1: command is executed every 1 minutes
Command:
* * * * * command

Example 2:3rd and 15 minutes per hour of execution
Command:
3,15 * * * command

Example 3: Execution at 3rd and 15 minutes from 8 o'clock in the morning to 11.
Command:
3,15 8-11 * * command

Example 4:3rd and 15 minutes of every two-day 8 o'clock in the morning to 11-point execution
Command:
3,15 8-11 */2 * command

Example 5:3rd and 15 minutes of each Monday from 8 o'clock in the morning to 11.
Command:
3,15 8-11 * * 1 command

Example 6:21:30 restart of SMB per night
Command:
* * * * */ETC/INIT.D/SMB restart


Example 7:4:45 restart SMB per month for 1, 10, 22nd
Command:
4 1,10,22 * */ETC/INIT.D/SMB restart


Example 8:1:10 restart SMB per Saturday, Sunday
Command:
1 * * 6,0/ETC/INIT.D/SMB restart


Example 9: Restart SMB every 30 minutes from 18:00 to 23:00 daily
Command:
0,30 18-23 * * */ETC/INIT.D/SMB restart


Example 10: Every Saturday night at 11:00am restart SMB
Command:
0 * * 6/ETC/INIT.D/SMB restart


Example 11: Restart SMB every hour
Command:
* */1 * * * */ETC/INIT.D/SMB restart


Example 12: Restart SMB every hour from 11 o'clock to 7 in the morning
Command:
* 23-7/1 * * * */ETC/INIT.D/SMB restart

Example 13:4th per month with 11 points per Monday to Wednesday restart SMB
Command:
0 4 * MON-WED/ETC/INIT.D/SMB restart

Example 14:4-point restart of SMB on January 1
Command:
0 4 1 Jan */ETC/INIT.D/SMB restart


Example 15: Execution of scripts within/etc/cron.hourly directory per hour
Command:
* * * * * Root run-parts/etc/cron.hourly
Description
Run-parts This parameter, if you remove this parameter, you can write a script name to run, not the directory name.



Ubuntu16 installing cron and using

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.