Linux Command: Use crontab

Source: Internet
Author: User
Linux Command: crontab uses -- Linux general technology-Linux technology and application information. The following is a detailed description. In Windows, there is a "Task Plan", and a shutdown file can be used as a bat file for Timed shutdown. in Linux, there is also a cron, whose configuration file is named crontab, we can use the crontab command to configure it.

Format
Second hour day month week [user name] command
Seconds 0-59
Hour 0-24
Day 1-31
Month 1-12
Week 0-6 (0 represents Sunday)

* It can match all numbers, that is, all time points.
-Use two integers separated by short lines to match the time points of these two values, for example, 0-9. In addition, use/to implement execution at specified intervals, for example, 0-59/30 is at, 4... these time points are executed.
, You can use commas to match any listed range or integer, such as 0-12, 14.
If the command is long, use the percent sign (%) to wrap the line.

Let's talk less. First, # crontab-h. I use Fedora 7, which is shown as follows:

Usage: crontab [-u user] file
Crontab [-u user] [-e |-l |-r]
(Default operation is replace, per 1003.2)
-E (edit user's crontab)
-L (list user's crontab)
-R (delete user's crontab)
-I (prompt before deleting user's crontab)
-S (selinux context)

-U specifies the user, which is the current user by default.
-E Editing: vim is used by default. If you are not familiar with vim, you can find a solution.
-L list timelines
-R Delete
-I prompts the user during the deletion.
-E is related to selinux.

The last two items are generally unavailable, so you don't have to worry about it. It is useful to have a crontab file. You can write a configuration in a file by yourself, and then use this command to write the configuration into crontab, -l you can see the effect. You may ask where these configurations are saved. In fact, there are three places where these configuration files are stored:/var/spool/cron;/etc/cron. d;/etc/crontab. Generally, we use the first one. So if you have configured crontab, you will find a file named after the user name under/var/spool/cron, you can directly open the editing without the crontab-e command, and the effect is the same. On the GUI, you can use other tools, such as gedit.
Related Article

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.