6
6

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

cron ファイルと各ユーザーの crontab

Last updated at Posted at 2016-12-22

cron ディレクトリー

パッケージインストールなどで配置される cron ファイルは以下のディレクトリーにあることが多い。

find /etc/cron* -type d
出力例
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly

cron ファイル

既に配置されているファイルは以下のように確認できる。

find /etc/cron* -type f | xargs ls -l
出力例
-rw-r--r--. 1 root root 128  4月  1  2016 /etc/cron.d/0hourly
-rwx------. 1 root root 219 11月  6 07:55 /etc/cron.daily/logrotate
-rwxr-xr-x. 1 root root 618  3月 18  2014 /etc/cron.daily/man-db.cron
-rw-------. 1 root root   0  4月  1  2016 /etc/cron.deny
-rwxr-xr-x. 1 root root 392  4月  1  2016 /etc/cron.hourly/0anacron
-rw-r--r--. 1 root root 451  6月 10  2014 /etc/crontab

各ユーザーの crontab の配置場所

各ユーザーの crontab ファイルは以下のディレクトリーに配置される。

ls -l /var/spool/cron
出力例
-rw-------. 1 root root 27 12月 22 19:14 root

全ユーザーの crontab 一括出力

for user in $(cut -f1 -d: /etc/passwd); do echo [$user]; crontab -u $user -l 2>/dev/null; done
出力例
[root]
1 * * * * echo "cron test"
[bin]
[daemon]
[adm]
[lp]
[sync]
[shutdown]
[halt]
[mail]
[operator]
[games]
[ftp]
[nobody]
[systemd-bus-proxy]
[systemd-network]
[dbus]
[polkitd]
[tss]
[sshd]
[postfix]
[chrony]
[takahara]
[apache]
[mysql]
6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?