Linux crontab perform tasks on a timed basis

Source: Internet
Author: User

1. The command to set the scheduled task is CRONTAB-E
When you use crontab for the first time, you will be asked to choose the editing tools to see people's preferences. Select one. If you want to change the default editing tool later, you can follow the prompts below to run the command "Select-editor" to make your selection.
Select an editor. To change later, run ' Select-editor '.
1./bin/ed
2./bin/nano <----easiest
3./usr/bin/vim.tiny

Choose 1-3 [2]: 3

And then it's crontab-e. After this command executes, the command line enters edit mode and can be set as prompted
The following example sets the echo "hello/n" >>/home/mingyuan/hello.txt this command executes every minute.
The asterisk denotes the meaning of "every", and if you do not use an asterisk, the 1 is the 1-minute time to execute the command. Like 2:1.

# m H Dom Mon Dow command
*/1 * * * * echo "hello/n" >>/home/mingyuan/hello.txt

It is also important to note that if you let crontab execute the script, you also need to take into account the problem of the path, it is recommended to use the absolute path in the configuration file, or you can add Cd/path/to/shell at the beginning of the command, this sentence, the current directory is switched to the directory where the shell, This is consistent with your command line switch to the directory where the shell script is executed. Otherwise, there is a good chance that a file could not be found. earnestly http://blog.csdn.net/telnetor/article/details/5555358

Linux crontab perform tasks on a timed basis

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.