Shell background scheduled task crontab usage

Source: Internet
Author: User
Crontab usage syntax: crontab [-uusername] |-l |-r |-e |-v-u: user of the specified crontabjob-l: list the job-e of the current crontab: use $ EDITOR to edit crontabjob-v: to list the current crontabjob status. some shells may not support-vcrontabf...

Crontab usage
 
Syntax: crontab [-u username] |-l |-r |-e |-v
-U: The user who specifies the crontab job
-L: list the current crontab job
-E: use $ EDITOR to edit crontab job
-V: lists the status of the current crontab job. some shells may not support-v
 
Crontab file format:
Each row corresponds to a cron job
Each line is divided into six parts. each part is separated by a space. the same part is separated by a comma.
Minute hour day_of_month month weekday command
* Used in the first five domains indicates all time points.
Minute: 0-59
Hour: 0-23,0 represents zero point
Day_of_month: 1-31
Month: 1-12
Weekday: 0-6, 0 indicates Sunday, and 1-6 indicates Monday to Saturday.
Command: The script or command to be executed.
 
$ Cat test_cron.sh
#! /Bin/sh
Export the system time to the file time.txt
Echo 'date'> time.txt
# View the current cronjob. the system prompts that the user's cronjob of habao is useless.
$ Crontab-l
No crontab for habao
 
# Add cronjob
$ Crontab-e
# No execution every minute
# Displaying the current system time # you can conveniently view the usage of scheduled jobs in the crontab file
* ***/Home/habao/test_cron.sh
 
# View the current cronjob
$ Crontab-l
# Do not edit this file-edit the master and reinstall.
#(/Tmp/crontab.3285 installed on Thu Sep 22 16:28:40 2011)
# (Cron version -- $ Id: crontab. c, v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Display the current system time
* ***/Home/habao/test_cron.sh
 
# Output file time.txt
$ Cat time.txt
Thu Sep 22 12 16:33:00 CST 2011
Thu Sep 22 12 16:34:00 CST 2011
Thu Sep 22 12 16:35:00 CST 2011
Thu Sep 22 12 16:36:00 CST 2011
Thu Sep 22 12 16:37:00 CST 2011
Thu Sep 22 12 16:38:00 CST 2011
Thu Sep 22 12 16:39:00 CST 2011
 
To modify the current cronjob, crontab-e
To delete the current cronjob, crontab-r

 
Author: "To_Be_Monster_Of_IT"

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.