1
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 3 years have passed since last update.

cron の ログを出力する

Posted at

こちらの記事を参考にしました。
cronを実行したログを出力する設定

Ubuntu 21.04 で確認しました。

/etc/rsyslog.d/50-default.conf
(省略)
cron.*                          /var/log/cron.log
(省略)

syslog の再起動

sudo systemctl restart rsyslog

syslog が動いていることを確認

$ sudo systemctl status syslog
● rsyslog.service - System Logging Service
     Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor prese>
     Active: active (running) since Mon 2021-05-03 15:03:28 JST; 4min 51s ago
TriggeredBy: ● syslog.socket
       Docs: man:rsyslogd(8)
             man:rsyslog.conf(5)
             https://www.rsyslog.com/doc/

テスト用のクローン設定

#
PATH=/usr/sbin:/usr/bin:/bin
#
#
2 * * * * /bin/date > /tmp/tmp501.txt
#
4 15 * * * date > /tmp/tmp502.txt
#
5 15 3 * * date > /tmp/tmp503.txt
#

作成されたログ

$ sudo more /var/log/cron.log 
May  3 15:03:48 www2 crontab[869302]: (uchida) BEGIN EDIT (uchida)
May  3 15:03:57 www2 crontab[869302]: (uchida) REPLACE (uchida)
May  3 15:03:57 www2 crontab[869302]: (uchida) END EDIT (uchida)
May  3 15:04:01 www2 cron[1010]: (uchida) RELOAD (crontabs/uchida)
May  3 15:04:01 www2 CRON[869316]: (uchida) CMD (date > /tmp/tmp502.txt)
May  3 15:05:01 www2 CRON[869382]: (uchida) CMD (date > /tmp/tmp503.txt)
May  3 15:09:01 www2 crontab[869569]: (uchida) LIST (uchida)
May  3 15:09:01 www2 CRON[869571]: (root) CMD (  [ -x /usr/lib/php/sessionclean 
] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
1
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
1
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?