Linux Automatic Restart service and Linux Restart service

Source: Internet
Author: User

Linux Automatic Restart service and Linux Restart service

The apache and mysql services are automatically restarted on a regular basis without restarting the server. The procedure is as follows:
I. Restart apache and mysql services at and every day
[Root @ www bin] # cd/opt/
[Root @ www opt] # vim reboot.txt
Enter the following content in the reboot.txt.txt file and save it.
0 12 *** service httpd restart
0 12 *** service mysqld restart
0 16 *** service httpd restart
0 16 *** service mysqld restart


2. Add the new file to the cron service.
[Root @ www opt] # crontab reboot.txt
[Root @ www opt] # crontab-l
0 12 *** service httpd restart
0 12 *** service mysqld restart
0 16 *** service httpd restart
0 16 *** service mysqld restart


Iii. Restart the cron Service
[Root @ www opt] #/sbin/service crond restart


========================================================
Note:
Cron is a linux scheduled execution tool that can run jobs without human intervention. Since Cron is a built-in service in Linux, but it does not automatically get up, you can use the following methods to start and close this service:
/Sbin/service crond start // start the service
/Sbin/service crond stop // close the service
/Sbin/service crond restart // restart the service
/Sbin/service crond reload // reload the configuration


Basic time table format:
* *** Program
Hour, day, month, and week commands
The 1st column indicates minute 1 ~ 59. Each minute is represented by * or */1.
The first column indicates the hour 1 ~ 23 (0 indicates 0 points)
The 3rd column indicates the date 1 ~ 31
The 4th column indicates the month 1 ~ 12
The Identification Number of column 5th is from day of the week to day ~ 6 (0 indicates Sunday)
6th columns of commands to run


When Column 1st is set to *, the program is executed every minute. When Column 2nd is set to *, the program is executed every hour, and so on.
When Column 1st is a-B, it indicates that execution is performed from the minute a to the minute B. If Column 2nd is a-B, it indicates that execution is performed from the hour a to the hour B, other analogy
When Column 1st is */n, it indicates execution is performed every n minutes. If Column 2nd is */n, it indicates execution is performed every n hours.
When Column 1st is a, B, c ,... a, B, c ,... execute in minutes. The 2nd columns are a, B, c ,... a, B, c... execute in hours, and so on


Some examples of crontab files:
30 21 ***/usr/local/etc/rc. d/lighttpd restart
The above example indicates restarting lighttpd at every night.
45 4, 10, 22 **/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that the lighttpd is restarted at on the 1st, 10th, and 22th of each month.
10 1 ** 6, 0/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates restarting lighttpd at every Saturday and Sunday.
0, 30 18-23 ***/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates restarting lighttpd every 30 minutes between and every day.
0 23 ** 6/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates restarting lighttpd at every Saturday.
**/1 ***/usr/local/etc/rc. d/lighttpd restart
Restart lighttpd every hour
* 23-7/1 ***/usr/local/etc/rc. d/lighttpd restart
Restart lighttpd every hour between PM and PM.
0 11 4 * mon-wed/usr/local/etc/rc. d/lighttpd restart
Restart lighttpd from every Monday to Wednesday on the 4th of each month.
0 4 1 jan */usr/local/etc/rc. d/lighttpd restart
Restart lighttpd at on January 1, January 1.
 
If you need to restart the server, add a line of 0 12 *** root init 6
 
After all, the SAVE and exit operations are often used in the linux vi editor.
Linux vi save and exit Operation: esc key, input: wq
Linux vi does not save exit Operation: esc key, type: q!
 
It is natural to use VIM for programming in linux.
At the beginning, I also felt uncomfortable with more commands and completely giving up the mouse!
However, after the early adaptation stage, I finally found that the mouse was abandoned, but it also improved the efficiency!


Go to the topic:
''(The point above the TAB): return to the position before the cursor jump.
Dd: delete a row.
5dd: Delete the five lines below the cursor.
Press the V Key to enter the visual mode, select the content to be copied, press yy to copy the selected content, and press p to copy the content to the new light mark or file as needed.
I: Enter the insert mode.
V: Enter the visual mode.
Esc: Return to Basic Mode
H, j, k, l: move the cursor up, down, and left
Vsp: left/right split window.
Sp: Upper/lower split window.
Ctrl + w: select in the window.
: Q! : Do not save and exit.
X: Save and exit.
W: Save only and do not exit.
X: delete a character.
U: undo
CTRL + O: Skip.
CTRL + R: undo the Undo.
: Help.
Zz: exit the Help window.
3 w: Move three words forward.
3b: Move three words backward.
CTRL + [: Jump to the cursor word.
CTRL + T: Skip?
9 k: Move nine rows up.
: E open a new file (it is useful in multi-window operations ).
Yaw: copy a word.
CTRL + B: move the cursor to the left header of the current row.
CTRL + E: move the cursor to the right header of the current row.
Vim-r doc.txt: Restore the file before modification.
:/Search for words
H: Jump to the first line.
M: Skip? Center.
L: Jump to the last line.
CTRL + d, u, f, B: Move down half screen, move up half screen, move down one screen, move up one screen.
Gg: at the beginning of the file
G: to the end of the file.
--: Locate the last file modification point.
CTRL + p, n: Query up one? Word to query a word down.
Zo: fold. The l key is also supported.
Zc: Close fold.
Zr: Hide all.
Zm: Hide all.
Zf: Create a fold.
ZR: open all folds (including nesting)
ZM: Close all folds (including nesting)
:! Ls to view the directory table.
: 'O, find the last modified file.
Wq: Save and exit.
Vim txt1 txt2 txt3 txt4, multiple files are opened at the same time,
Which of the following files can be opened at the same time? Time (multiple windows are recommended)
N, next file,
N3, go down to the third file.
First, the first file.
Last, the last file.
:/S # kkk # ccc # g. Replace the kkk in the file with ccc.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.