- 최신
- 최다 투표
- 가장 많은 댓글
Hi,
As described on the following amazon-linux-2023 Github repository issue, they have decided not to include in the AMIs in AL2023 as the same (in fact, better) functionality is provided by systemd.
It's one of the components we have decided not to include in the AMIs in AL2023 as the same (in fact, better) functionality is provided by
systemd
. The functionality ofsystemd
timers (see https://www.freedesktop.org/software/systemd/man/systemd.timer.html ) is a superset of what you could do with cron, including powerful functionality around timing accuracy and resource control. Timer accuracy and jitter can be important to avoid thundering herd problems in larger clusters of systems.
That's completely correct.
AL2023 doesn't contain a scheduler by default, and installing cronie
gives you a scheduler, and puts in place the directory structure you are looking for.
[ec2-user@ip-172-31-34-136 ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
SUPPORT_END="2028-03-01"
[ec2-user@ip-172-31-34-136 ~]$ ls -l /etc/cron.d
ls: cannot access '/etc/cron.d': No such file or directory
[ec2-user@ip-172-31-34-136 ~]$ rpm -qa | grep cron
crontabs-1.11-24.20190603git.amzn2023.0.2.noarch
[ec2-user@ip-172-31-34-136 ~]$ sudo yum install -y cronie
Last metadata expiration check: 0:01:07 ago on Tue Aug 8 07:09:30 2023.
Dependencies resolved.
========================================================================================================
Package Architecture Version Repository Size
========================================================================================================
Installing:
cronie x86_64 1.5.7-1.amzn2023.0.2 amazonlinux 115 k
Installing dependencies:
cronie-anacron x86_64 1.5.7-1.amzn2023.0.2 amazonlinux 32 k
Transaction Summary
========================================================================================================
Install 2 Packages
Total download size: 147 k
Installed size: 341 k
Downloading Packages:
(1/2): cronie-anacron-1.5.7-1.amzn2023.0.2.x86_64.rpm 488 kB/s | 32 kB 00:00
(2/2): cronie-1.5.7-1.amzn2023.0.2.x86_64.rpm 1.4 MB/s | 115 kB 00:00
--------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 147 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : cronie-1.5.7-1.amzn2023.0.2.x86_64 1/2
Running scriptlet: cronie-1.5.7-1.amzn2023.0.2.x86_64 1/2
Created symlink /etc/systemd/system/multi-user.target.wants/crond.service → /usr/lib/systemd/system/crond.service.
Installing : cronie-anacron-1.5.7-1.amzn2023.0.2.x86_64 2/2
Running scriptlet: cronie-anacron-1.5.7-1.amzn2023.0.2.x86_64 2/2
Verifying : cronie-anacron-1.5.7-1.amzn2023.0.2.x86_64 1/2
Verifying : cronie-1.5.7-1.amzn2023.0.2.x86_64 2/2
Installed:
cronie-1.5.7-1.amzn2023.0.2.x86_64 cronie-anacron-1.5.7-1.amzn2023.0.2.x86_64
Complete!
[ec2-user@ip-172-31-34-136 ~]$ !ls
ls -l /etc/cron.d
total 4
-rw-r--r--. 1 root root 128 Jan 30 2023 0hourly
[ec2-user@ip-172-31-34-136 ~]$ rpm -ql cronie
/etc/cron.d
/etc/cron.d/0hourly
/etc/cron.deny
/etc/pam.d/crond
/etc/sysconfig/crond
/lib/systemd/system/crond.service
/usr/bin/cronnext
/usr/bin/crontab
/usr/lib/.build-id
/usr/lib/.build-id/77
/usr/lib/.build-id/77/ce0dc802519e6ddb9035f2b7c701de7ae14e75
/usr/lib/.build-id/af
/usr/lib/.build-id/af/01cc35016f7f1f78bcc21e177464c69919e276
/usr/lib/.build-id/f2
/usr/lib/.build-id/f2/f5a5adc27bf01a7232269c77d07796a9f792e9
/usr/sbin/crond
/usr/share/doc/cronie
/usr/share/doc/cronie/AUTHORS
/usr/share/doc/cronie/ChangeLog
/usr/share/doc/cronie/README
/usr/share/licenses/cronie
/usr/share/licenses/cronie/COPYING
/usr/share/man/man1/cronnext.1.gz
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/man/man8/cron.8.gz
/usr/share/man/man8/crond.8.gz
/var/spool/cron
[ec2-user@ip-172-31-34-136 ~]$
Hello.
Yes, if you want to use cron in the same way as before, installing cronie would be the best way to handle this.
https://docs.aws.amazon.com/ja_jp/linux/al2023/release-notes/all-packages-AL2023.1.html
If you want to run scripts, etc. periodically without installing anything, you can do so by setting systemd's timer.
https://manpages.debian.org/testing/systemd/systemd.timer.5.en.html
In addition, you can read also https://jainsaket-1994.medium.com/installing-crontab-on-amazon-linux-2023-ec2-98cf2708b171 to have a detailled walk-through of the install