Linux crontab and using salt for management

Source: Internet
Author: User

First, Introduction:

I have recently inadvertently seen salt with a cron module, here today to introduce the Linux crontab and the management of crontab through the salt cron.

Second, the introduction of Linux crontab:

The crontab is used to set instructions that are executed periodically. The command reads the instruction from the standard input device and stores it in a "crontab" file for later reading and execution. Crontab stored instructions are activated by daemons, Crond often run in the background, and every minute checks whether a scheduled job needs to be executed.

2.1. Startup and shutdown of Crond:

#View the status of Crond[[Email protected] ~]#Service Crond Status#Close Crond[[Email protected] ~]#Service Crond Stop#Start Crond[[Email protected] ~]#Service Crond Start#Restart Crond[[Email protected] ~]#Service Crond Restart#Reload Crond[[Email protected] ~]#Service Crond Reload

2.2. All configuration Files

Crontab exists in the/etc directory cron.hourly,cron.daily,cron.weekly,cron.monthly,cron.d five directories and crontab,cron.deny two files.

Cron.daily is a job that executes once a day;

Cron.weekly is a job that executes once a week;

Cron.monthly is a job that executes once a month;

Cron.hourly is the job that executes once per hour;

CRON.D is a task that the system automatically needs to do on a regular basis, but it is not performed by the hour, by day, by week, by month.

The contents of/etc/crontab are as follows:

[[Email protected] ~]#Cat/etc/crontabshell=/bin/Bashpath=/sbin:/bin:/usr/sbin:/usr/Binmailto=Root#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

A/etc/cron.deny file is a feature that controls which users are not allowed to use crontab.

2.3. User Configuration file:

Each user has their own cron configuration file, through Crontab-e can be edited, in general, we finished editing the user's cron configuration file after the exit, the system will automatically be stored in the/var/spool/cron/directory, the file is named after the user name.

The cron service for Linux is to read all the contents of/var/spool/cron/,/etc/crontab,/etc/cron.d every other minute.

2.4. Cron Command format:

| -r | - E} -u: Specify a user-e: Perform a text editor to set the user (current user or specified user) time table, the default text editor is vi.-r: Delete User Time table.-L: Lists the user Time table.

2.5. Cron file Format:

* * * * * *  command time    Moon Week the  1th column represents minutes 1~59, per minute with * or */1 for the2nd column represents the hour 1~( 0 = 0 points) The 3rd column represents the date 1~to the 4th column represents the month 1~ 5th Column identification number week 0~6(0 for Sunday) 6th Column command to run

2.6. Special Users:

[[email protected] cron] # crontab-l # Lines below here is managed by Salt,does not edit @reboot/root/cgroup_mkdir.sh

@reboot means running after booting and running only once, with the same effect as in/etc/rc.local.

In addition, there are:

string Meaning------           -------@reboot Run once, at startup @yearly Run once a,"0 0 1 1 *". @annually (same as @yearly) @monthly Run once a month,"0 0 1 * *". @weekly Run Once a week,"0 0 * 0". @daily Run Once a day,"0 0 * * *". @midnight (same as @daily) @hourly Run Once an hour,"0 * * * *".

2.7. Run once every 10 seconds:

Third, through salt to manage crontab:

3.1.

Not to be continued ...

Linux crontab and using salt for management

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.