Set the periodic task

※ cron is a linux under the regular implementation of the tool, you can run the job without the need for manual intervention.

Because Linux Cron is a built-in services, but it does not auto-up, you can start with the following methods to close this service:

service crond start // Start Service

  service crond stop // shut down service

  service crond restart // restart the service

  service crond reload // reload the configuration

 

Below this is the command timed tasks:

crontab -u // set a user's cron service, usually root user needs this parameter when executing this command

crontab -l // set out in detail the contents of a user cron services

   crontab -r // not delete a user's cron service

   crontab -e // edit a user's cron service

   For example, set the root view their own cron: crontab -u root -l

   For another example, root want to delete the cron setting fred: crontab -u fred -r

   When editing cron service, edit the contents of some of the formats and conventions, enter: crontab -u root -e

 

※ 1, linux work scheduling is divided into the following two categories:

Work performed by the system: The system periodically work to be performed, such as data backup system, clear the cache

Work performed by a person: a user work to be done on a regular basis, such as every 10 minutes to check the mail server for new letter, which work by each user their own settings.

2.cron file syntax:

Minute hour day Monday user command

0-59 0-23 1-31 1-12 0-6 root command?

3. Remember the meaning of several special symbols:

"*" Representatives within the range of numbers,

"/" Stands for "every"

"-" represents the numbers from one to a certain number,

"" Several separate discrete digital

 

※ available crontab -e command to edit, edit the corresponding user / var / spool / cron cron the file, you may directly modify / etc / crontab file;

 

Example periodic task set:

  1. Open daily 7:00 sshd

 

2. Eleven pm every day to close sshd

 

3. emptied once every five days notice FTP server directory / var / ftp / pub

 

4. six or seven points a week and a half, restart the httpd service

 

5. weekly one hundred thirty-five 17:30, packing backup / etc / httpd directory

 

 

6. The backup log file / var / log / messages

 ( Common kernel message log information and various applications, including start, I / O error, network error, program failure, etc.)

 

7. The backup log file / var / log / cron 

(Crond time information periodically scheduled task generated)

 

 

 8. backup log file / var / log / dmesg 

(Various times during boot program information)

 9. backup log file / var / log / maillog 

(Entering or outgoing e-mail system activity)

 

10. The backup log file / var / log / lastlog

(Each user has recently logged events) 

 

 11. The backup log file / var / log / secure

(User authentication security-related time information)

 

 12. The backup log file / var / log / wtmp 

(Each user login, logout and system startup and shutdown events)

 

 13. backup log file / var / log / btmp

 (Failures, incorrect login attempts and validation events)

 

Packing compression / etc 14. 24 points every night / passwd / etc / shadow / etc / group

/etc/gshadow  /etc/gpasswd

 

15. Monday of every five minutes lists the disk usage

 

16. The daily at 8:30 and the Internet time synchronization time synchronization server pool.ntp.org

 

 

Guess you like

Origin www.cnblogs.com/canflyfish/p/11362991.html