linux contab

Definition Format: * * * * * Command
m (0-59), H (0-23) D (1-31) M (1-12) W (0-7)
weeks with 1-6 W represented respectively: a ... five, six weekly Sunday Sun foreigner in a foreign country equivalent to the first working day so Sunday with 0 and 7 show can;
exceptions, for example:
* * * * * the Command 3, 15 per minute to perform the Command
* * * * * hour of 3,15 perform division
* / 2 * * * executed once every 2h
* * * * 18-23 18-23 points per day performed once per minute
3.20 * 18-23 * 18 * day -23 points of 3 minutes, 20 minutes to perform a
stdin stdout stderr:
0-1-2
redirection and append
cmd> file.txt
equivalent to write overwrites the old cmd >> file2.txt equivalent to append, in the old behind additionally
Shell I / O redirection,



. Command parameters: -u user: to set a user's crontab service, for example, "- u ixdba" represents a set ixdba user's crontab service, this parameter generally have root user to run. file: file is the file name of the command, said it would file as a crontab task list file and loaded into crontab. If you do not specify the file on the command line, crontab command will accept commands entered on standard input (keyboard), and load them crontab. -e: crontab edit the contents of a user's files. If you do not specify a user, then edit the current user's crontab file. -l: Displays the contents of a user's crontab file, if you do not specify a user, then displays the current contents of the user's crontab file. -r: delete a user's crontab file from / var / spool / cron directory, if you do not specify a user, the default is to delete the current user's crontab file. -i: When you delete a user's crontab file to confirm tips
? two .how to use it how to write linux timed plan to execute the script
. 2.1 Create a script file that you want to perform, which means you have to understand the basic shell command syntax, for example:
startTime = $ (DATE M-%%% Y-D \% H:% M:% S)
echo $ startTime
to implement a print a stamp, for example, to achieve more than a basic shell script command , of Course, you CAN IT the make of Better!
2.2 to create a timed plan, plan is crontab:
crontab -e -u testuser execution enter vi mode:
create a timed plan for testuser, if not specified, the default is the currently logged on user created directly -e crontab:
EG:
Run.sh create a copy of a file execution timing plan
* / 1 * * * * /absDirpath/dirParent/run.sh > /usr/local/test/logtest.txt
Of course, if you do not want to export any information to your linux you can use the> / dev / null 2> & 1

Guess you like

Origin www.cnblogs.com/SunshineKimi/p/11275614.html