Kapan entri dalam cron.daily
(dan .weekly
dan .hourly
) dijalankan, dan apakah bisa dikonfigurasi?
Saya belum menemukan jawaban pasti untuk ini, dan saya berharap ada satu.
Saya menjalankan RHEL5 dan CentOS 4, tetapi untuk distro/platform lain akan lebih bagus juga.
Untuk distribusi yang Anda sebutkan:
Pada CentOS 5.4 (Seharusnya sama untuk RHEL5)
grep run-parts /etc/crontab
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
Jadi cron.daily berjalan pada pukul 04:02 pagi.
Sama dengan CentOS 4.8
Dari halaman manual:
Cron also searches for /etc/anacrontab
/etc/anacrontab
dalam sistem saya (Fedora 12):
1 5 cron.daily Nice run-parts /etc/cron.daily
7 25 cron.weekly Nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly Nice run-parts /etc/cron.monthly
Lihat juga man anacrontab
Untuk CentOS 6, Anda perlu grep/etc/anacrontab dan jawabannya bervariasi jika server/laptop/dekstop/etc telah dimatikan atau tidak.
cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
Shell=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
#period in days delay in minutes job-identifier command
1 5 cron.daily Nice run-parts /etc/cron.daily
7 25 cron.weekly Nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly Nice run-parts /etc/cron.monthly
Jadi, antara jam 3 pagi dan 10 malam (setelah reboot dan setelah mesin sudah menyala selama 5 menit ^^), jalankan /etc/cron.daily. Jika tidak ada reboot, pekerjaan harus berjalan pada 3:05 AM++.
** As defined by START_HOURS_RANGE
^^ As defined by FIELD_TWO (i.e. the 5 after the 1 in the cron.daily line)
++ plus a random time between 0 and 45 minutes as defined by RANDOM_DELAY
Referensi: http://linux.die.net/man/5/anacrontab
Untuk sistem SuSE (khususnya SLES 11.1 dan openSuSE 10.3) waktu menjalankan skrip /etc/cron.daily harian dikontrol oleh nilai DAILY_TIME variabel yang diset dalam (etc)/sysconfig/cron file.
Jika variabel DAILY_TIME tidak diatur, standarnya adalah: (waktu boot terakhir + 15 menit).
Di Ubuntu, Anda akan menemukan file/etc/crontab, tempat konfigurasi ini. Saya kira itu adalah sesuatu yang serupa pada RH dan Centos.
CentOS6.x/RedHat6.x menginstal secara default paket cronie-anacron. Kamu harus:
yum instal cronie-noanacron
yum menghapus cronie-anacron
Maka sekarang Anda memiliki /etc/cron.d/dailyjobs untuk mengonfigurasi waktu jadwal terbaik untuk pekerjaan harian, mingguan, dan bulanan Anda.
Saya menggunakan Slackware (14.0), dan tidak memiliki /etc/crontab
. Juga, anacron
bukan bagian dari distribusi.
Solusi pada sistem saya sesederhana menjalankan crontab -l
sebagai root:
[email protected]:~# crontab -l
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null. We'll do this here since these jobs should run
# properly on a newly installed system. If a script fails, run-parts will
# mail a notice to root.
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this. If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
Dari /etc/anacrontab
di sistem Ubuntu 9.10 saya:
1 5 cron.daily Nice run-parts --report /etc/cron.daily
7 10 cron.weekly Nice run-parts --report /etc/cron.weekly
@monthly 15 cron.monthly Nice run-parts --report /etc/cron.monthly
Tidak ada fasilitas seperti itu sejauh Solaris yang bersangkutan. Cukup gunakan entri crontab biasa untuk tugas sehari-hari.
Pembaruan OpenSuse 42.x:
/ etc/crontab menampilkan file/usr/lib/cron/run-crons yang seharusnya dijalankan setiap 15 menit.
/ usr/lib/cron/run-crons pada gilirannya (memiliki baris kode may) yang mencari variabel yang disebut DAILY_TIME di/etc/sysconfig/cron
File menunjukkan;
# At which time cron.daily should start. Default is 15 minutes after booting
# the system. Example setting would be "14:00".
# Due to the fact that cron script runs only every 15 minutes,
# it will only run on xx:00, xx:15, xx:30, xx:45, not at the accurate time
# you set.
DAILY_TIME=""
Setel ke waktu yang Anda butuhkan dan mulai ulang cron via;
systemctl restart cron.service