Help us understand the problem. What is going on with this article?

Linux【 crontab 】

オプション

# エディタを開いて crontab を編集する
crontab -e

# crontab の内容を表示する
crontab -l

#【ユーザ】で指定したユーザの cron 設定。root ユーザのみ使用可能
crontab -u【ユーザ】

書式

# +------------ 分 (0 - 59)
# | +---------- 時 (0 - 23)
# | | +-------- 日 (1 - 31)
# | | | +------ 月 (1 - 12)
# | | | | +---- 曜日 (0:日 - 6:土)
# | | | | |
  * * * * * 【実行されるコマンド】
# アスタリスク(*)は全範囲指定。* * * * * は毎分実行。

# 5分間隔で実行
*/5 * * * *

# 10分間隔で実行
*/10 * * * *

実行時間をずらす場合(5分間隔)

# 0, 5, 10 ... 55分
*/5 * * * * 

# 1, 6, 11 ... 56分
1-56/5 * * * *

# 2, 7, 12 ... 57分
2-57/5 * * * *

# 3, 8, 13 ... 58分
3-58/5 * * * *

# 4, 9, 14 ... 59分
4-59/5 * * * *

実行ディレクトリはホームディレクトリ

実行したいシェルスクリプト等がホームディレクトリではない場合、
crontab には cd で移動後に実行するように記載。

# cd【移動先】;【実行したいシェルスクリプト】
* * * * * cd destination_directory; ./shellscript.sh

実行状況の確認

# 実行ログ最新の10件を表示
tail /var/log/cron

【参考】
https://webkaru.net/linux/crontab-command/
https://qiita.com/onomame/items/71646c5517a39bcd01cc
https://qiita.com/nmatayoshi/items/84128fd7663bcd2beb95
https://qiita.com/doranekohc/items/c9bca52eed96916be9b6
http://piyopiyocs.blog115.fc2.com/blog-entry-976.html
https://hodalog.com/how-to-inspect-cron-logs/

r18j21
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした