Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux Task Scheduler (at, crontab)     - ASM required disk format process in Solaris platforms (Linux)

- Linux performance optimization features Tuned and ktune (Linux)

- Use SecureCRT to transfer files between Linux and Windows (Linux)

- Windows environment Android Studio v1.0 Installation Guide (Linux)

- Physical structure and process disk IO (Linux)

- Three easy open source firewall on the Linux platform (Linux)

- Puppet 3.x installed on Debian 7 (Server)

- Linux system started to learn: how to solve the xxx is not in the sudoers file error (Linux)

- NaSC using simple mathematical operations on Ubuntu and Elementary OS (Linux)

- iostat command Detailed (Linux)

- Binary Packages Golang (Linux)

- Towards Docker (Server)

- Ubuntu resolve sudo: source: command not found error (Linux)

- Ubuntu 14.10 used ifconfig commands to manage your network configuration (Linux)

- MySQL multi-instance configuration (Database)

- Linux source code to install Apache and solutions to common errors (Server)

- Ubuntu 14.10 install KDE Plasma 5.2 (Linux)

- HttpClient Tutorial (Programming)

- CentOS 6.5 dual card configuration, one of the external network, a local area network connection (Linux)

- Installation and management of Linux applications (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:      
 
- The new task parallel library feature in .NET 4.6 (Programming)
- Node.js installed on Ubuntu Upstream version (Linux)
- Python 2.7 installed on CentOS 6.5 (Linux)
- Linux using TCP-Wrapper Service Management (Linux)
- How to add and delete bookmarks in Ubuntu (Linux)
- Linux see whether there is a hacker program (Linux)
- Using the Linux VNC service (Server)
- Definition Format Oracle basis of various statements (Database)
- Haproxy multi-domain certificate HTTPS (Server)
- Oracle 11g on Linux system boot from the startup settings (Database)
- About Linux operating system security (Linux)
- What factors affect the performance of Java calls (Programming)
- Java Set and List in the relationship and difference (Programming)
- CentOS6.6 ordinary users to use sudo command to borrow root user privileges (Linux)
- Udev: Device Manager for Linux Fundamentals (Linux)
- Oracle inverted reverse function (Database)
- Zabbix monitoring disk IO status (Server)
- How to contribute code on GitHub uploads (Linux)
- HDFS Distributed File System Resource Manager Developer summary (Server)
- CentOS 7 open ports (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.