FreeBSD Timer Execution Program (CRON)

Source: Internet
Author: User
Tags log variables

The UNIX system provides cron and AT commands that allow the system and users to run certain programs on a regular basis without the need to manually start them.

Using Cron for periodic execution of a command, in order to use it, you must edit the crontab file. The system default/etc/crontab file is:

#/etc/crontab-root ' s crontab for FreeBSD
#
# $Id: crontab,v 1.13 1996/01/06 22:21:37 ache Exp $
# FROM:ID:CRONTAB,V 1.6 1993/05/31 02:03:57 CGD Exp
#
Shell=/bin/sh
path=/etc:/bin:/sbin:/usr/bin:/usr/sbin< br> home=/var/log
#
#minute hour mday month wday who command
#
*/5 * * * * root/usr/ Libexec/atrun
#
# rotate log files every hour, if necessary
0 * * * * root/usr/sbin/newsyslog
#
   # do daily/weekly/monthly Maintenance
0 2 * * * root/etc/daily 2>&1 | sendmail root
30 3 * * 6 root/etc/weekly 2>&1 | SendMail Root
5 1 * * Root/etc/monthly 2>&1 | sendmail root
#
# time zone change adj  Ustment for wall CMOS clock,
# does No, if you are have UTC CMOS clock.
# The Adjkerntz (8) for details.
1,31 0-4 * * * root/sbin/adjkerntz-a

In this crontab file, several environment variables are set first, and Cron executes the file by setting these environment variables and then executing the corresponding commands at the time specified in each column. First column minutes, specify the number of minutes per hour for the implementation of the corresponding procedures, the second column for the first few hours a day of implementation procedures, the third column in the first days of the month, the fourth column in the first few weeks, the first day of the week, column VI for the implementation of the user identity, seventh as the order

Ordinary users can also use the crontab command to create and maintain their own crontab files. Since the user cannot change the identity of the executing program, the user's crontab does not need the sixth column-the user identity of the executing program, but simply follows the command to be executed. Use the CRONTAB-E command to edit your own crontab file in the appropriate format using the editor, or use "crontab-l" to list the contents of an existing Crontab file, and of course only the root user can view the crontab file of another user:

$ crontab -l
12 0 * * * /home/wb/bin/getfiles

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.