Usage shell background regular tasks of

  
crontab crontab usage

syntax: crontab [-u username] | -l| -r| -e| -v
-u: Specify the user of the crontab job
-l: List the current crontab job
-e: Edit the crontab job with $EDITOR
-v: List the status of the current crontab job some shell may not support -v

crontab file format to fill:
row for each cron job
each row is divided into six parts, each separated by a space, a part of the same Separated by comma
minute hour day_of_month month weekday command
The last five fields use *, which means all time points
minute:0-59
hour:0-23,0 represents zero
day_of_month:1-31
month:1-12
weekday:0-6,0 for Sunday, 1-6 for Monday to Saturday
command: script or command to be executed

$cat test_cron.sh
#!/bin/sh
#Output system time to file time.txt
echo `date`>>time.txt
#View The current cronjob, the system prompts the user habao's cronjob
$ crontab -l
no crontab for habao
#Add cronjob
$ crontab –e
#Execute once every minute
#Show current system time#Write in crontab file to view the purpose of timed job
* * * * * /home/habao/test_cron.sh

# View 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 $ )
# show the current time
* * * * * /home/habao/test_cron.sh

# view the output file time.txt
$ cat time.txt
Thu Sep 22 16:33:00 CST 2011
Thu Sep 22 16:34:00 CST 2011
Thu Sep 22 16:35:00 CST 2011
Thu Sep 22 16:36:00 CST 2011
Thu Sep 22 16:37:00 CST 2011
Thu Sep 22 16:38:00 CST 2011
Thu Sep 22 16:39:00 CST 2011

To modify the current crontab cronjob -e
Crontab –r to delete the current cronjob
Copyright © Windows knowledge All Rights Reserved