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)
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
* * * * *
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 * * *'
每晚的 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 發布文章使用:只允許注冊用戶才可以訪問!