# Linux Crontab 排程設定

<span style="color: rgb(0, 0, 0);">**範例**</span>

<span style="color: rgb(0, 0, 0);">**\# 查看自己的 crontab**</span>  
<span style="color: rgb(0, 0, 0);">**crontab -l**</span>  
<span style="color: rgb(0, 0, 0);">**\# 查看指定使用者的 crontab**</span>  
<span style="color: rgb(0, 0, 0);">**sudo crontab -u gtwang -l# 編輯 crontab 內容**</span>  
<span style="color: rgb(0, 0, 0);">**crontab -e**</span>  
<span style="color: rgb(0, 0, 0);">**\# 編輯指定使用者的 crontab**</span>  
<span style="color: rgb(0, 0, 0);">**crontab -u gtwang -e#** </span>  
<span style="color: rgb(0, 0, 0);">**刪除 crontab 內容**</span>  
<span style="color: rgb(0, 0, 0);">**crontab -r**</span>

<span style="color: rgb(0, 0, 0);">**\# ┌───────────── 分鐘 (0 - 59)**</span>  
<span style="color: rgb(0, 0, 0);">**\# │ ┌─────────── 小時 (0 - 23)**</span>  
<span style="color: rgb(0, 0, 0);">**\# │ │ ┌───────── 日 (1 - 31)**</span>  
<span style="color: rgb(0, 0, 0);">**\# │ │ │ ┌─────── 月 (1 - 12)**</span>  
<span style="color: rgb(0, 0, 0);">**\# │ │ │ │ ┌───── 星期幾 (0 - 7，0 是週日，6 是週六，7 也是週日)**</span>  
<span style="color: rgb(0, 0, 0);">**\# │ │ │ │ │**</span>  
<span style="color: rgb(0, 0, 0);">**\# \* \* \* \* \* /path/to/command**</span>

<span style="color: rgb(0, 0, 0);">**\# 每天早上 8 點 30 分執行**</span>  
<span style="color: rgb(0, 0, 0);">**30 08 \* \* \* /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 每週日下午 6 點 30 分執行**</span>  
<span style="color: rgb(0, 0, 0);">**30 18 \* \* 0 /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 每週日下午 6 點 30 分執行**</span>  
<span style="color: rgb(0, 0, 0);">**30 18 \* \* Sun /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 每年 6 月 10 日早上 8 點 30 分執行**</span>  
<span style="color: rgb(0, 0, 0);">**30 08 10 06 \* /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 每月 1 日、15 日、29 日晚上 9 點 30 分各執行一次**</span>  
<span style="color: rgb(0, 0, 0);">**30 21 1,15,29 \* \* /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 每隔 10 分鐘執行一次**</span>  
<span style="color: rgb(0, 0, 0);">**\*/10 \* \* \* \* /home/gtwang/script.sh --your --parameter**</span>

<span style="color: rgb(0, 0, 0);">**\# 從早上 9 點到下午 6 點，凡遇到整點就執行**</span>  
<span style="color: rgb(0, 0, 0);">**00 09-18 \* \* \* /home/gtwang/script.sh --your --parameter**</span>