Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ How common Linux automation tasks     - CentOS 6.5 dual card configuration, one of the external network, a local area network connection (Linux)

- Jigsaw project will solve the problem of Java JAR hell Mody (Programming)

- About MongoDB query method according to fuzzy field (Database)

- Cacti monitoring service Nginx (Linux)

- File SUID, SGID, Sticky property (Linux)

- Linux system monitoring, top command of the diagnostic tool Detailed (Linux)

- Ubuntu installed racing game Speed Dreams 2.1 (Linux)

- Setting Derby as Linux / Windows running as a service from the start (Server)

- ImageMagick Tutorial: How to cut images in Linux command line (Linux)

- Infinispan 8 new Redis cache storage implementation (Linux)

- CoreOS Linux introduces Kubernetes kubelet (Server)

- Using Linux / Unix Text processing (Linux)

- Android Action Compendium (Programming)

- Android Studio interface-related settings (Linux)

- Java multi-threaded in a three way (inheritance, implementation, anonymous inner classes) (Programming)

- Lua4.0 interpreter entrance (Programming)

- GNU Linux use diff to generate a patch with the patch (Linux)

- Linux System Getting Started Learning: modify environment variables in Linux PATH (Linux)

- Use C program in JavaScript (Programming)

- CentOS 7 How to install MySQL Server (Database)

  How common Linux automation tasks
  Add Date : 2018-11-21      
  Linux system's web site at the time of operating state, we often need to maintain the site, for example, to view and respond to the remaining resources, log segmentation, data processing, to perform a specific task in a specific state, etc., these will need linux can automatically perform certain any task. This post describes how common linux automation tasks.

 Achieve "Automation" has the following advantages:
 Save manpower, a script is enough.
 At night you can avoid the automatic execution site traffic peak, does not affect the efficiency of the site during the day.
 By accurate, complete set of circumstances, it will not go wrong.
 Of course, the most important thing is peace of mind, do not knock some frequent commands.
 Boot should be our needs very often, we often need to boot automatically execute some commands to open the services, processes, etc., with which we do not have to enter the same bunch of commands when you switch.

chkconfig command

 Use chkconfig command can be set at different levels start to start a particular service or program.

 Let me talk about the linux run level:

 Level 0 means: showing off
 Level 1 means: single-user mode
 Level 2 indicates: no network connection multi-user command line mode
 Level 3 means: multi-user command line mode with networking
 Level 4 indicates: unavailable
 Level 5 indicates: multi-user mode with GUI
 Level 6, said: Restart
chkconfig command is as follows:

chkconfig --list // command has been set to open from the start list.
xxxd 0: off 1: off 2: on ... 6: off // result list, showing the xxxd service level at start of 2345 the situation will start automatically.
chkconfig --add xxxd // add a xxxd services to the task list
chkconfig [--level 1/2 /../ 6] xxxd on / off // set xxxd with service n state on / off, omitted in the 2345-level Open [] within
chkconfig --del xxxd // task list xxxd service delete
Edit rc.d files

 You can also edit files /etc/rc.d/ directory directly boot from the start. There are a lot of files in this directory, rcn.d is in a starting condition for the start of the next file the case n folders from Kai file rc, rc.sysinit, init.d all modules of the system or system settings [clip].

 We use vim rc.local rc.local file editor to customize your own self-priming plan. Command is very simple, just like in the usual operation. Such as / usr / local / apache / bin / apachectl start showing boot from the start apache server.

at regular tasks realization
at a simple function is a simple timer task program, it can only be a one-time regular tasks, which are used as follows:

#at time // at plus time to start at the command
at> operation // input operations to be performed
at> Ctrl + D // Press Ctrl + D to exit the command editor
 Common forms of its time as follows

at H: m tomorrow // H point m points the next day
at now n minutes / hours / days / weeks // in n minutes / hours / days / weeks +
at midnight at midnight // = - =
at H: m pm / am // in the morning / afternoon H point m points
 We can also look at the current command in the / var / spool / at files. Also note that, linux default atd process closed, need to manually open.

crontab achieve timing tasks
linux built-in cron process can help us to achieve these requirements, cron shell script with very complex instructions is not a problem.

cron Introduction

cron daemon is a subsystem consisting of small utilities and configuration files, and on almost all UNIX-like systems can be found in a certain style of cron, we can use the ps aux | grep cron daemon crond found.

 We often use the crontab command cron table shorthand, it's cron configuration file, or you can call the job list, we can find the configuration file in the following folder.

/ Var / spool / under cron / directory is stored in each user including root's crontab tasks, each with creator named
/ Etc / crontab file is responsible for scheduling the various management and maintenance tasks.
/etc/cron.d/ This directory is used to store any crontab files or scripts to be executed.
 We can also put the script in /etc/con.hourly,/etc/con.daily,/etc/con.weekly,/etc/con.monthly directory, make per hour / day / week and month once.
use crontab

We used commands are:

crontab [-u username] // omit the user table showing the operation of the current user's crontab
    -e (edit worksheets)
    -l (listed worksheet commands)
    -r (delete as work)

We enter the current user's crontab -e worksheet editor, vim is a common interface. Each line is one command.

crontab command configured time + movement, took part in its time, hour, day, month, Friday species, operators have

* All figures within the range of
/ How many numbers every
- From X to Z
Hash digital
 Here are a few examples.

 Time Notes

002 512 * // in the December 25 0:00
* / 5 * * * * // every 5 minutes
* * * * // 4-6 day 456 Dian
* * * * 2,5 // every Tuesday and Friday

With a simple shell script

If our command logical judgment very complex operation, and then directly edit the crontab bit difficult, then, we can use the shell script. Its origin, definition and classification title match, say no more, we direct it usage.

We used to use vim vim /usr/sh/test.sh edit a shell script

#! / Bin / sh // declares the beginning of shell script a = "hello world" // define a shell variable echo $ a // familiar echo, the output of a variable

Then crontab -e to edit crontab, add * / 5 * * * * /usr/sh/test.sh test.sh once every five minutes to run the script, you can also use / phppath / php /filepath/test.php to use php process to execute php program.
- Bad name two variables (Linux)
- Flow control message transmission between RAC (Database)
- Caffe + Ubuntu 14.04 64bit + CUDA 6.5 configuration instructions (Linux)
- VMware virtual machine to install CentOS 6.2 (Linux)
- Linux System Getting Started Learning: Repair (Linux)
- Linux protobuf-c (Linux)
- Oracle 11g maintenance partitions (Seven) - Modifying Real Attributes of Partitions (Database)
- The difference between VMware virtual machine network mode (Linux)
- How to network to share files between Windows, MAC and Linux (Linux)
- Based AutoYaST automated installation of SUSE practice (Linux)
- Linux Beginner Guide: Installing packages on Ubuntu and Fedora (Linux)
- How to use Quagga BGP (Border Gateway Protocol) router to filter BGP routing (Linux)
- Linux dual physical network card set to a virtual NIC (Linux)
- Ubuntu development Nodejs (Linux)
- Linux command Detailed chpasswd bulk edit user password (Linux)
- CentOS yum install LAMP (Server)
- KVM QEMU virtual machine installation configuration under CentOS (Linux)
- SQL Server 2012 failover looksalive check and is alive check (Database)
- JavaScript prototype and the prototype chain (Programming)
- Git version rollback (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.