linux下 corntab 定時任務設置

1. crontab常用的幾個命令格式

crontab -l //顯示用戶的crontab文件的內容

crontab -e //編輯用戶的crontab文件的內容

crontab -r //刪除用戶的crontab文件

在第一次使用crontab -e,會要求選擇編輯器,我選擇是vim.basic

編輯文件,內容如下:

root@ubuntu:/var/log# crontab -e
# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
* * * * * /home/xwdreamer/eclipse-workspace/RELEASED_V2_10_20180331/iotkit-embedded/output/release/bin/linkkit-example

eg:

每分鐘執行      * * * * *
每五分鐘執行    */5 * * * *
每小時執行      0 * * * *
每天執行       0 0 * * *
每週執行       0 0 * * 0
每月執行       0 0 1 * *
每年執行       0 0 1 1 *

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章