2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AlmaLinux9.0でcron設定

Last updated at Posted at 2022-11-30

ジョブスケジューリングデーモンであるcronで、スクリプトを日々の決められた時間に自動実行されるよう設定した時のメモ。

cronがインストールされていることを確認。

# dnf search crontabs
メタデータの期限切れの最終確認: hh:mm:ss 時間前の yyyy年mm月dd日 hh時mm分ss秒 に実施しました。
========================================== 名前 完全一致: crontabs ==========================================
crontabs.noarch : Root crontab files used to schedule the execution of programs

crontab設定。(毎日AM2:00にスクリプト実行設定)

# crontab -e
0 2 * * * hogehoge.sh

cronサービスの再起動

systemctl restart crond

サーバ起動の度にcron実行するよう設定。

systemctl enable crond

cronの実行状況確認、「active (running)」となっているのでOK。

# systemctl status crond
● crond.service - Command Scheduler
     Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-11-30 14:22:21 JST; 12s ago
   Main PID: 12909 (crond)
      Tasks: 1 (limit: 203240)
     Memory: 952.0K
        CPU: 6ms
     CGroup: /system.slice/crond.service
             mq12909 /usr/sbin/crond -n
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?