Linux Schedule Cron All In One


Linux Schedule Cron All In One

定時任務 / 定時器

GitHub Actions

Scheduled events

# Cron syntax has five fields separated by a space, and each field represents a unit of time.

┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
│ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
│ │ │ │ │                                   
│ │ │ │ │
│ │ │ │ │
* * * * *

https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#schedule

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    # This example triggers the workflow every 15 minutes
    - cron:  '*/15 * * * *'

https://github.com/xgqfrms/gitHub-secrets-all-in-one/blob/main/.github/workflows/auto_commit.yml

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    # This example triggers the workflow every 15 minutes
    - cron:  '8 8 * * *'

https://github.com/learning-js-by-reading-source-codes/vanillawebprojects/blob/main/.github/workflows/schedule.yml

每晚的 21:30 重啟

# 每晚的 21:30 重啟smb
30 21 * * * /etc/init.d/smb restart

https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/crontab.html#smb

cron logs

$ tail -f /var/log/cron
tail: /var/log/cron: No such file or directory



➜  ~ grep ./auto-install-npm.sh /var/log/cron
grep: /var/log/cron: No such file or directory

➜  ~ grep "auto-install-npm.sh" /var/log/cron
grep: /var/log/cron: No such file or directory
      

cron logs

https://stackoverflow.com/questions/4811738/how-to-log-cron-jobs

# 2>&1, 標准輸出和錯誤輸出二合一

* * * * * ./auto-install-npm.sh >> /var/log/auto-install-npm.log 2>&1

linux 2>&1

https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean

refs

https://github.com/xgqfrms/linux/issues/15



©xgqfrms 2012-2020

www.cnblogs.com 發布文章使用:只允許注冊用戶才可以訪問!



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM