Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux Crontab Timing task command Detailed     - Squid proxy server configuration under Linux (Server)

- Ubuntu 15.04 and Ubuntu 14.04 installed Cinnamon 2.6 (Linux)

- CentOS 6.6 command-line automatic completion (Linux)

- Ubuntu users to install voice switch instructs the applet (Linux)

- Ubuntu 12.04 installation OpenCV2.4.1 and compile test (Linux)

- Java integrated development environment common set of operations (Linux)

- Oracle 12C modify spfile path (Database)

- Oracle ordinary users show parameter method (Database)

- CentOS / Linux SWAP partitions added (Linux)

- Linux log management make the system more secure (Linux)

- CentOS7 set boot directly into the command line interface (Linux)

- Oracle data row split multiple lines (Database)

- How to set IonCube Loaders in Ubuntu (Linux)

- Can not empty the Recycle Bin to repair problems in Ubuntu 14.04 (Linux)

- Install Jetty on CentOS / RHEL 6.X (Server)

- Introduction Linux namespace (Linux)

- C ++ based foundation: the difference between C and C ++ (Programming)

- Use FirewallD build dynamic firewall (Linux)

- Nginx request processing (Server)

- How to customize your Linux desktop: Gnome 3 (Linux)

 
         
  Linux Crontab Timing task command Detailed
     
  Add Date : 2018-11-21      
         
         
         
  At work requires a database automatic backup every day at 0:00 so it is necessary to establish a regular task. I chose to add a scheduled task execution shell Crontab files in Linux. shell have a database backup file command.

One. Crontab Introduction

Function crontab command at a certain time interval schedule execution of commands.

two. Check / etc / crontab file

vim / etc / crontab

three. File / etc / crontab job description of each line in the following format:

minute hour day month dayofweek command

    minute - an integer from 0 to 59
    hour - integer from 0 to 23
    day - an integer from 1 to 31 (must be a valid date of a given month)
    month - an integer from 1 to 12 (or, as Jan or Feb abbreviated month)
    dayofweek - integer from 0-7, 0 or 7 is used to describe Sunday (or Sun or Mon shorthand representation)
    command - the command to be executed (available as ls / proc >> / tmp / proc or execute custom script commands)

    root represents the root user to run
    run-parts is represented followed by a folder, to execute all the scripts folder

    For the above statement, the asterisk (*) indicates that all available values. * In the example refers to month, said the monthly execution (need to comply with other restrictions) the command.
    Hyphen integer between (-) represents an integer column, for example, 1-4 means that the integer 1,2,3,4

Specified values separated by commas. Such as: 3,4,6,8 represent the four specified integer.

The symbol "/" specified Step setting. "/ " represents the step value. As 0-59 / 2 defined execution once every two minutes. Step value can also be indicated by an asterisk. Such as * / 3 is used to run the specified task to run every three months.

With "#" at the beginning of the comment line, it will not be executed.

If a cron task needs on a regular basis rather than by the hour, day, week, month to execute, you need to add /etc/cron.d directory. All files and directories under the / etc / crontab same syntax, view examples:

# Record the memory usage of the system every monday
# At 3:30 AM in the file / tmp / meminfo
30 3 * * mon cat / proc / meminfo >> / tmp / meminfo
# Run custom script the first day of every month at 4:10 AM
10 4 1 * * /root/scripts/backup.sh

 In addition to the root user's crontab configuration user can perform scheduled tasks. All user-defined crontab is stored in the directory / var / spool / cron, the task will be executed to the identity of the creator. To create a crontab as a specific user, the first user to log in, execute the command crontab -e, the system will start specified in the VISUAL or EDITOR the editing software crontab. File contents and / etc / crontab same format. Examples are as follows:

0 3 * * * /home/dbbackup/db1backup.sh backup
0 4 * * * /home/dbbackup/db2backup.sh backup

Showing daily 3:00 to perform /home/dbbackup/db1backup.sh backup, 4 point execution /home/dbbackup/db2backup.sh backup, if it is performed once every five minutes could be changed to:

* / 5 * * * * /home/dbbackup/db2backup.sh backup

When changes need to be saved crontab file will be saved in the following file into / var / spool / cron / username. Filename based on user name and different.

cron service is checked every minute /etc/crontab,/etc/cron.d/,/var/spool/cron change files under. If changes will be downloaded to the memory. Therefore, even if a crontab file is changed, the program does not require a reboot. Recommended custom tasks using crontab -e command to add, after exiting with /etc/init.d/crond restart command to restart crond process, said no official documents to restart the process, but I can not be met without rebooting run the task situation. Beginning not know / etc / crontab file, the run-parts What does it mean, directly to the command in the / etc / crontab format plus not always run, and then I run-parts means followed by the folder.

 four. Start crontab services Close

sbin / service crond start // Start Service
/ Sbin / service crond stop // Close Service
/ Sbin / service crond restart // restart the service
/ Sbin / service crond reload // reload the configuration
     
         
         
         
  More:      
 
- Linux file permissions and access modes (Linux)
- Java Graphics2D Paint (Programming)
- Switching Virtual Machine + Ubuntu graphical interface and terminal interface (Linux)
- MySQL InnoDB table --BTree basic data structures (Database)
- Into the Java keyword instanceof (Programming)
- To install Ganglia (Linux)
- Redhat Close SELinux correct step (Linux)
- How to enhance the Nagios server security (Linux)
- Linux md5sum verify file integrity (Linux)
- Docker study notes (Server)
- How to understand the difference between synchronous and asynchronous non-blocking blocking (Programming)
- How to deploy Icinga server (Server)
- installation of Vim plugin YouCompleteMe under Ubuntu 15.04 (Linux)
- Oracle JDK installation under Ubuntu Linux (Linux)
- Wildcards and special symbols usage comments under Linux (Linux)
- Java factory pattern (Factory mode) (Programming)
- How to use the TF / SD card making Exynos 4412 u-boot boot disk in Mac (Linux)
- 29 practical examples Linux system / network administrator of nmap (Linux)
- Zabbix installation under Linux (Server)
- LogStash log analysis display system (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.