Linux automatically runs crontab learning Notes

Source: Internet
Author: User
Tags tmp file cron script
Linux automatically executes crontab learning notes on the linux platform. if you need to implement the task scheduling function, you can write a cron script to implement it. By default, the crond process is started when a task is executed at a certain frequency. the crond process does not need to be started or closed by the user. The crond process is responsible for reading and executing the scheduling task. in linux, the crontab learning notes are automatically executed. on the linux platform, if you need to implement the task scheduling function, you can write a cron script. By default, the crond process is started when a task is executed at a certain frequency. the crond process does not need to be started or closed by the user. The crond process reads and executes scheduling tasks. you only need to write the corresponding scheduling script to the cron scheduling configuration file. Cron scheduling files include the following: crontabcron. dcron. dailycron. hourlycron. monthlycron. weekly if the task is not executed in hourly monthly weekly mode, you can write the corresponding crontab to crontab or cron. d directory. Example: execute the script every minute/opt/bin/test-cron.sh can be in cron. d New script echo-date.sh content is */1 * root/opt/bin/test-cron.sh at the specified time run the task can also be controlled at the specified time run the task such: at-f test-cron.sh-v where-f specifies the script file,-v specifies the run time quote: ea946d690b = "lophyxp"] first use contab-l> contabs. tmp export the contab configuration. Edit the contabs. tmp file. Add a line in the following format: minute hour day month week command for example 10 3 ** hello is to execute the hello program at 03:10 every Saturday or Sunday. 15 4 ** 4-6 hello is to execute the hello program from pm on Thursday to Saturday. Use the contab contabs. tmp command to import the new configuration. Generally, it is not recommended to directly modify the relevant configuration files under/etc. How to start the cron process:/etc/init. d/crond start: run the command chkconfig -- add crond to start the cron process at startup. Method 2: add cron to the startup script: # rc-update add vixie-cron defaultcrontab-l # View your task crontab-e # Edit your task crontab-r # DELETE the user's crontab content Example 2: system cron settings: in the/etc/crontab file, you can set the tasks scheduled by the system. of course, to edit this file, you must have the root permission 0 7 * root mpg123 ~ Example of/wakeup.mp3 by hour, day, month, and week: 0 4 ** 0 root emerge -- sync & emerge-uD world # every Sunday, update the system 0 2 1 ** root rm-f/tmp/* # on the first day of each month, clean up files in/tmp 0 8 6 5 * root mail robin
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.