Linux crontab for automated tasks, linuxcrontab

Source: Internet
Author: User

Linux crontab for automated tasks, linuxcrontab

On the server, we often need to regularly and automatically let the program back up data, back up the program, execute a process, and so on. On the linux server, crontab is generally used, while on windows, scheduled tasks are used, crontab is a common scheduled execution program in linux. It allows the program to automatically execute an operation without manual intervention. The following operations take cent-OS as an example.

1. Install crontab

Yum install vixie-cron crontabs // install crontab,
// Vixie-cron is the main program of cron.
// The crontabs package is used to install, uninstall, or list the tables used to drive the cron daemon.
Chkconfig crond on // sets the crond process to start automatically when it is started.
Service crond start // start the process

2. How to Use crontab

Crontab-l // view the crontab execution task list
Crontab-e // Add crontab to execute the task
Crontab-r // Delete the user's task
Crontab-u <User Name> // specify the task to be set to the specified user

3. crontab command format

A) Basic Format

Format Minute in minutes Hour Date dayofmonth Month Weekly dayofweek Command
Value Range 0 ~ 59 0 ~ 23 1 ~ 31 1 ~ 12 0 ~ 7 Command Line

In crontab, there are four special values, *,-/, which indicate the codes respectively.

* For example, 0 12 *** ls indicates that the ls command is executed every 12 o'clock every month.
, Indicates multiple values. For example, 1, 60, 12, 8, 9 * ls indicates that the ls command is executed at and 16 on January 1, September 8.
- Represents the range value. For example, 0 3-6 *** ls indicates that the ls command is executed from 3 to 6 points every day.
/N It indicates that the ls command is executed every n hours, for example, 0 1 *** ls indicates that the ls command is executed every 1 hour.

B) Operate instances

Run the data backup program at 24 o'clock every day: 0 24 ***/root/backup. sh

Clean the log program at every Sunday: 0 3 ** 7/root/clear. sh

 


Linux automatic task crontab not executed

Haha .. I have encountered similar problems. But now it is fixed. Last modified
*/15 */home/www/run.
The problem of time format can be analyzed. This is also your problem.

LINUX crontab does not automatically execute tasks

Check whether your test. sh file has the executable permission. My original file is not executed because it does not have the executable permission.

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.