Add a self-starting task in Ubuntu

Source: Internet
Author: User

Add the cron settings of the self-starting task System in Ubuntu: the/etc/crontab file can be used to set the tasks scheduled by the system. Of course, you must have the root permission to edit the file. Let's open/etc/crontab to see the cron Syntax: # for vixie cron ##$ Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4, v 1.1 2005/03/04 23:59:48 ciaranm Exp $ ### Global variablesSHELL =/bin/bashPATH =/sbin: /bin:/usr/sbin:/usr/binMAILTO = rootHOME =/# check scripts in cron. hourly, cron. daily, cron. weekly and cron. monthly0 ***** root rm-f/var/spool/cron/lastrun/cron. hourly1 3 *** root rm -F/var/spool/cron/lastrun/cron. daily15 4 ** 6 root rm-f/var/spool/cron/lastrun/cron. weekly30 5 1 ** root rm-f/var/spool/cron/lastrun/cron. monthly */10 ***** root test-x/usr/sbin/run-crons & usr/sbin/run-crons the task that is actually described in the last five lines, each line represents a scheduled task, which is divided into three parts: the first part, a bunch of strange numbers and stars. This part describes the task execution cycle and time, we will explain it in detail later. In the second part, all the above files are "root", which describes the users who run the task. The third part is the complete command to be executed. The first part is divided into five small parts, which can be numbers or asterisks, representing minutes, hours, dates, months, and weeks. Let's look at an example: 0 7 * root mpg123 ~ The asterisk (*) indicates that the asterisk (*) is not restricted. In the preceding example, mpg123 ~ /Wakeupyun, put a song and wake yourself up from your sleep ~ The range of each part is as follows: minute 0 ~ 59 hours 0 ~ 23 Date 1 ~ 31 months 1 ~ 12 weeks 0 ~ 6. The week range is 0 ~ 6, 0 represents Sunday, 1 ~ 6 represents Monday ~ Saturday. Let's look at more examples: 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

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.