Daemon cron dapat dikonfigurasi untuk menjalankan pekerjaan sistem terjadwal. Untuk pekerjaan sistem, pengguna yang izinnya menjalankan perintah juga harus ditentukan. Masukkan nama pengguna di antara definisi waktu (lima bidang pertama) dan perintah (yang sekarang menjadi bidang ketujuh).
Anda menentukan pekerjaan sistem di file /etc/crontab atau di file di direktori /etc/cron.d/. Crontab default di sistem CentOS/RHEL adalah seperti yang ditunjukkan di bawah ini.
# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executedCATATAN :Meskipun Anda dapat menambahkan baris tambahan ke /etc/crontab, Anda tidak boleh menghapus baris default.
Pekerjaan yang ditentukan dalam file /etc/crontab di atas menjalankan skrip yang terdapat dalam direktori berikut pada interval yang ditunjukkan:
Direktori | Interval |
---|---|
/etc/cron.hourly | /etc/cron.hourly Pekerjaan yang berjalan setiap jam. |
/etc/cron.daily | Pekerjaan yang dijalankan setiap hari. |
/etc/cron.weekly | Pekerjaan yang berjalan setiap minggu. |
/etc/cron.monthly | Pekerjaan yang berjalan setiap bulan. |
# ls -lrt /etc/cron.hourly/ total 4 -rwxr-xr-x. 1 root root 392 Mar 29 2017 0anacron [root@jamiericho4 ~]# ls -l /etc/cron* -rw-------. 1 root root 0 Mar 29 2017 /etc/cron.deny -rw-r--r--. 1 root root 451 Dec 27 2013 /etc/crontab /etc/cron.d: total 16 -rw-r--r--. 1 root root 128 Mar 29 2017 0hourly -rw-r--r--. 1 root root 173 Sep 23 2016 awslogs -rw-r--r--. 1 root root 179 Sep 23 2016 awslogs_log_rotate -rw-r--r--. 1 root root 108 Jun 13 2017 raid-check /etc/cron.daily: total 16 -rwx------. 1 root root 219 Jan 24 2017 logrotate -rwxr-xr-x. 1 root root 618 Mar 17 2014 man-db.cron -rwx------. 1 root root 208 Feb 4 2016 mlocate -rwx------. 1 root root 256 Sep 1 10:34 rhsmd /etc/cron.hourly: total 4 -rwxr-xr-x. 1 root root 392 Mar 29 2017 0anacron /etc/cron.monthly: total 0 /etc/cron.weekly: total 0
Cara Menjadwalkan Pekerjaan dengan perintah 'at' di Linux
Cara menjadwalkan Pekerjaan dengan Cron di Linux