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: