Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux Task Scheduler (at, crontab)     - In the case of using cgroups Ubuntu 14.04 and Docker (Linux)

- Oracle Shared Server Configuration (Database)

- Automatic Clear date directory shell script (Linux)

- Installation and use the telnet command under CentOS 6.x (Linux)

- CentOS iptables firewall configuration (Linux)

- JavaScript original values and complex values (Programming)

- Linux kernel programming parameter passing between modules and function calls (Programming)

- Use Epoll develop high-performance application server on Linux (Server)

- Learn about EditText little depth (Programming)

- Linux operating system security tools of the Logs (Linux)

- Oracle 12C RAC on temporary table space Enlighten (Database)

- Gentoo: startx appeared Failed to load module Problem Solving (Linux)

- Json data with double backslashes to a single backslash Json data processing (Programming)

- Bash variable expansion modifier (Programming)

- LVS + Keepalived the DR mode (Server)

- Zabbix configure DataGuard monitoring (Database)

- Linux performance monitoring - CPU, Memory, IO, Network (Linux)

- AngularJS asynchronous service testing and Mocking (Programming)

- Linux more command Detailed (Linux)

- By creating a personal technology blog Detailed GitHub (Linux)

 
         
  Linux Task Scheduler (at, crontab)
     
  Add Date : 2017-01-08      
         
         
         
  Linux Task Scheduler, the timing to perform certain tasks or periodically perform certain tasks

Schedule:

In the next time a task is performed once: at, batch

Periodically perform a task: crontab

After the task is finished executing, liunx will report to the current user via e-mail

E-mail service: smtp: simple mail transmission protocol

linux path: / var / spool / mail / USERNAME

View Mail command: yum install mailx Mail Service Installation

mail order:

mail: enter the interactive interface to send and receive mail;

mail -s 'SUBJECT' username @ hostname

mail -s 'SUBJECT' username @ hostname < / PATH / FROM / SOMEFILE

COMMAND | mail -s 'SUBJECT' username @ hostname

at the command:

Hosting a job the next time to run:

It supports the use of the job queue:

The default is a queue;

Ctrl + d: submit the job

at [option] ... TIME

TIME:

(1) absolute time

HH: MM,

MMDD [CC] YY, MM / DD / [CC] YY, DD.MM. [CC] YY or [CC] YY-MM-DD

tomorrow

(2) Relative time

now + # UNIT

minute, hour, day, week

(3) fuzzy time

midnight

noon

teatime

Common options:

-q QUEUE: at job queue;

-f / PATH / FROM / SOMEFILE: read the job to run from the specified file;

-l: List View other operating jobs in the job queue; equivalent to using atq command;

-c AT_JOB_NUM: Check to be content to run the job;

-d: delete the specified job; equivalent atrm

batch:

Selected by the system run more idle resources specified in the task on their own;

crontab: Recurring schedule

Daemon: crond

There are two types of periodic tasks:

(1) system cron jobs; there is no default user to run, so it is necessary to specify to run additional person;

/ Etc / crontab

vim command

# 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

Seven fields:

The first five fields: time

user-name: In what user to run the task

command to be executed: To run the task

(2) user cron task: submitted by some users, the default will be submitted to the identity of the run, so no additional persons designated to run;

/ Var / spool / cron / USERNAME

vim command; not recommended

crontab command: Recommendation

# 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

# | | | | |

# * * * * * Command to be executed

5 time points:

Min: Effective in the range 0-59;

Hours: 0-23

Day: 1-31

Month: 1-12

Of the week: 0-7

Note: The number a few months and a few weeks is not recommended to be used simultaneously;

E.g:

          6 * * * *

      Time notation:

      *: Corresponding to the time point of the effective value at each time point range;

      -: A continuous specific time frame, 3-7

      ,: A discrete point in time, 3,5,7

      / #: How much time per valid time range; for a given frequency;

                                                        1-30 / 4 * / 4

                                          5 * / 3 * * * / bin / echo "howdy"

                                          5 7 ** 1-5 / bin / echo "howdy"

crontab command:

                  crontab [-u user] [-l | -r | -e]

    -uuser: not manage their own cron jobs, cron task but the target user specified; only the root user with administrative cron jobs other authority; default to manage their own;

      -l: list, task lists;

      -r: remove, remove all tasks;

      -e: edit, edit, open a shell session of the current default editor to edit the cron task table;

note:

      (1) If you do not want to receive e-mail notification of the results of the task execution:

                                  COMMAND> / dev / null

                                  COMMAND &> / dev / null

      (2) For the crontab file is concerned, there are special functions%;% if the command will appear, remember to escape, or use single quotes reference to them;

      (3) crontab PATH variable and user variables are not identical, therefore, it recommended in a cron task to use absolute paths

                                  /root/bin/a.sh

Exercise:

1. Monday to Saturday, 3:20, run the cp command to / etc / directory archive save, storage location for the / backups / etc-YYYY-MM-DD;

~] # Crontab -l

20 3 * * 1-6 / bin / cp / etc -rpf / backups / etc-'file \% Y - \% M - \% D '

2. every Sunday 2:30 to run the cp command to / etc / fstab file backup, storage location of / backup / fstab-YYYY-MM-DD-hh-mm-ss

~] #crontab -l

30 2 * * 7 / bin / cp / etc / fstab / backup / fstab-'file \% Y - \% M - \% D - \% H - \% M - \% S '

3. The day before 0:00, get / proc / meminfo file all names beginning with M or S line, /statistics/meminfo.txt appended to the file, and the daily news, to add similar ====== ========= divider;

~] #crontab -l

00 0 * * * echo "===============" >> / proc / meminfo | egrep "^ S | ^ M" / proc / meminfo >> / statistics / meminfo.txt
     
         
         
         
  More:      
 
- How to modify the Sublime in Tab four spaces (Linux)
- CentOS 7.0 running Docker kernel error solution (Server)
- Linux security settings (Linux)
- The hashcode method of Java (Programming)
- To install Xen in Ubuntu 12.04 (Linux)
- The Linux kernel and AVL tree in red-black tree (Programming)
- Ubuntu 14.04 installation configuration GNOME Classic interface (Linux)
- WEB-based Android Remote Tools Python implementation (Programming)
- Monitoring Linux System 7 command-line tool (Linux)
- Setting CentOS firewall open port (Linux)
- To disable the function by pressing Ctrl-Alt-Del to restart the system in RHEL / CentOS 5/6 (Linux)
- Linux common network tools: batch scanning of hosting services netcat (Linux)
- git checkout generated in the use of temporary br (Linux)
- How Glances monitoring system on Ubuntu (Linux)
- Installation configuration CUDA under Ubuntu 14.04 (Linux)
- How to Install Android Studio on Ubuntu 15.04 / CentOS7 (Linux)
- AngularJS asynchronous service testing and Mocking (Programming)
- The bulk batch multiple rows of data collect (Database)
- Generators and iterators in Python (Programming)
- How to use static, class, abstract method in Python (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.