Linux crontab instance

Source: Internet
Author: User

Linux crontab instance

Linux Tutorial example-package and store the files under "/etc" to the "/usr/lobal" directory every two minutes.

· Step 1: edit the current user's crontab and save it.
Terminal input:
> Crontab-u root-l # view the timer set by the root user
> Crontab-u root-e # enter the vi compilation Mode

00-59/2 ****/bin/bash/usr/local/crontab_test.sh

# Exit the editing mode of Esc and enter ": wq" at the end of the file to save the file.

· Step 2: Write the crontab_test.sh file in the/usr/local directory.

#! /Bin/bash
Cd/usr/local
DD = 'date + % d'
MM = 'date + % m'
SS = 'date + % s'

Backetc?dd=mm=ss.tar.gz
Tar zcvf $ BACKETC/etc
Echo "filebackup finished! "

· Step 3: after creating a file, enter the following command on the terminal to modify the file permissions:
> Chmod u + x crontab_test.sh

-----------

(Wait a few minutes and go to the/usr/local directory to check whether there are more * .tar.gz files !)

Appendix: For details about how to use crontab in Linux, refer to the "man crontab" command!

The above content is purely an individual learning summary and does not represent any group or organization. If you cannot understand it, please forgive me!

Use crontab in Linux to create scheduled tasks

Routine scheduling of crontab in Linux

Linux crontab does not run troubleshooting

Ubuntu uses crontab for scheduled tasks

Linux scheduled task (at batch crontab anacron)

This article permanently updates the link address:

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.