pseudowire

調べたことを書き残す

cronの基本操作など

CRONの初期操作

# CRONのインストール
apt install -y cron

# CRONの起動状況確認
/etc/init.d/cron status

# CRONの起動
/etc/init.d/cron status

CRONの基本操作

# crontabを別名でコピー
$ crontab -l > crontab-custom

# 別名コピーしたファイルを編集
$ vi crontab-custom

#編集したファイルをcrontabに読み込ませる
$ crontab crontab-custom 

#反映されたことを確認
$ crontab -l

CRONの基本設定

#Pythonの絶対パスの確認
$ which python3

/usr/local/bin/python3


# CRON実行結果をログ出力(日時をログ名にしてログ出力)
$ vi crontab-custom

* * * * * [python3 Full Path] [program Full Path] >> [logfileのパス]/[logfile name]-`date +\%Y-\%m-\%d-\%H-\%M-\%S`.log 2>&1

# 例)4時から7時の間、5分おきに実行
*/5 4-7 * * *

参考リンク

nishinatoshiharu.com

qiita.com