Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ How common Linux automation tasks     - Oracle Database Restore (Database)

- To install Python-Pip and Fabric under CentOS / Ubuntu (Linux)

- Hadoop safe hftp (Server)

- Vim configuration instructions (Linux)

- Linux / Centos anti CC attack script (Linux)

- Java thread lifecycle (Programming)

- Why do I prefer Git (Linux)

- The best tools and techniques to find data on a Unix system (Linux)

- Ubuntu update bug fixes Daquan (Linux)

- Java input and output common class Scanner (Programming)

- Github with .gitignore ignore specified file (Linux)

- Cobbler Add custom YUM source (Linux)

- How to set up HTTPS policies for older browsers (Server)

- Ubuntu 14.10 / 14.04 / 12.04 How to install Kodi 14.0 RC3 (Linux)

- Linux and hardware (Linux)

- The strings in Python reside (Programming)

- Java, extends and implements Usage (Programming)

- The difference between VMware virtual machine network mode (Linux)

- Swift defined type conversion and type aliases (typealias) (Programming)

- Cancel Root Command History under Linux (Linux)

 
         
  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
 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.
     
         
       
         
  More:      
 
- Installation and configuration under Linux SVN server - Backup - Recovery - Scheduled Tasks (Server)
- Use PuTTY to access the virtual machine Linux under Windows xp (Programming)
- Eclipse improve the efficiency of good habits (Programming)
- Configure shared library PCRE (Linux)
- Ubuntu install Avast antivirus software (Programming)
- Ubuntu 14.10 install KDE Plasma 5.2 (Linux)
- Oracle 11g modify MEMORY_TARGET (Database)
- How to Install Puppet in the Ubuntu 15.04 (Server)
- High-performance JavaScript DOM programming (Programming)
- Mhddfs: multiple smaller partitions into one large virtual storage (Linux)
- RedHat Redis Linux installation (Database)
- Hibernate4 The Hello World (basic environmental structures) (Programming)
- How to install Go1.5 source development environment on Mac (Server)
- Linux System Getting Started Learning: Debian download, installation and graphical interface (Linux)
- Linux automatically install service components and optimize the kernel parameters (Linux)
- ASM Management - How to Rename diskgroup (Database)
- Linux FTP setting file description (Server)
- Linux Crontab Timing task command Detailed (Linux)
- How to become a better Node.js developers in 2016 (Programming)
- LinkedList Basic Usage (Programming)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.