linux 定時器怎麼用 crontab 基礎

2021-09-24 06:39:38 字數 923 閱讀 9093

建立定時器

# 檢視

$ crontab -l

# 建立

$ crontab -e

# 每分鐘輸出一次當前時間

* * * * * echo `date` >> /demo.log

# 檢視定時

$ cat /etc/crontab

shell=/bin/bash

path=/sbin:/bin:/usr/sbin:/usr/bin

mailto=""

# for details see man 4 crontabs

# example of job definition:

# .---------------- minute (0 - 59)

# | .------------- hour (0 - 23)

# | | .---------- day of month (1 - 31)

# | | | .------- month (1 - 12) or jan,feb,mar,apr ...

# | | | | .---- day of week (0 - 6) (sunday=0 or 7) or sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * user-name command to be executed

# 刪除

$crontab -r

# 檢視cron的狀態,設為開機啟動

$ systemctl status crond (檢視狀態)

$ systemctl enable crond (設為開機啟動)

$ systemctl start crond (啟動crond服務)

複製**

詳情參考鏈結

Linux之定時器cron

一 配置任務crontab e 編輯使用者的定時任務檔案 var spool cron crontabs user 當前使用者的定時任務在該檔案下 示例 1 echo hello echo uname a 每分鐘執行shell命令cront格式 分 時 日 月 周 shell命令 二 儲存修改,預設...

linux 定時器怎麼用 crontab 基礎

建立定時器 檢視 crontab l 建立 crontab e 每分鐘輸出一次當前時間 echo date demo.log 檢視定時 cat etc crontab shell bin bash path sbin bin usr sbin usr bin mailto for details s...

linux 定時器怎麼用 crontab 基礎

建立定時器 檢視 crontab l 建立 crontab e 每分鐘輸出一次當前時間 echo date demo.log 檢視定時 cat etc crontab shell bin bash path sbin bin usr sbin usr bin mailto for details s...