Linux System Management Preliminary (VI) set up scheduled Tasks

Source: Internet
Author: User

A timed task is to set the system to perform an action at a fixed time, either by executing a command, deleting an xx file, or by executing a set of scripts, such as backing up a data file, and so on. This part is not difficult, but it is very important for daily operation and maintenance.

First, order crontab

Options:

-U <user> Specify a user, not the current user, with the Who am I command to see
-E New Scheduled task
-L lists Scheduled tasks. With the-u option, you can list scheduled tasks for developing users
-R Delete the scheduled task, Note that he will all your scheduled tasks are deleted, use caution!!!
-I confirm before delete, with rm-i a meaning

Crontab configuration file under /etc/crontab path

Crontab commands are written in this format:

Shell defines the shell type
Path defines the binary command file paths, and some of the new installer's command files cannot be executed if they are not in these paths handy
MAILT0 defines who the execution results are sent to

The following five asterisks are used to set when to perform a scheduled task. respectively, "Minutes, hours, days, months, weeks"

Crontab through the CRONTAB-E command into the scheduled Task editor, the operation is consistent with VI.

Second, the actual demonstration of a crontab planning task.
1, write the scheduled task, set he will be in two minutes after the ls-la/tmp output to/tmp/crontab.log

2. Start Crond Service

Systemctl Start Crond

3. See the results

Note that we usually execute the cat, LS and other commands output to the screen, this is not output to the screen, but to export him to a file.

Third, the operation of crontab precautions
1, the best after the command with the correct output and error output statements, to facilitate the inspection of scheduled task execution results
Like this:

2. Backup the configured cron configuration file
Everyone's crontab is stored in/var/spool/cron, such as Root's cron configuration file:/var/spool/cron

Copy the file that corresponds to your user name to a different location when you are backing up.

3. Execute the output of restart command
I executed it in the crontab.

The command is to restart the computer in two minutes,
And then he's outputting a

There's nothing in the 1.txt ...

Linux System Management Preliminary (VI) set up scheduled Tasks

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.