Apa itu cron, cron job, cron script, crontab
cron is a Unix command for scheduling one or more commands (collectively called a cron script or cron job) to be automatically executed on the computer at a specified time(s), usually periodically, such as emailing daily reports.
Cron is a daemon process, which means it runs continuously in the background, waiting to run a specified operation at predefined times or when specific events occur.
crontab is a Unix command that creates or modifies a file (called a crontab file) that contains a cron table (cron tab) or list of Unix shell commands, each having a specified time of execution by the operating system.
From website: http://www.free-webhosts.com/definition/cron.php
command yg digunakan untuk cronFrom website: http://www.free-webhosts.com/definition/cron.php
crontab –l = list semua cron
crontab –e = untuk edit cron
crontab –r = remove semua cron user
(esc) :q! = keluar tanpa save
(esc) :wq! = save n keluar
! = guna utk force.
Kalau guna keyboard, jangan sekali-kali guna number disebalah kanan.
Bawah ni example utk buat cron berdasarkan waktu.
Field | 1 | 2 | 3 | 4 | 5 | 6 |
Function | Minute | Hour | Day of month | Month of year | Day of week | Command |
Ranges | 0-59 | 0-23 | 1-31 | 1-12 | 0-6 Begins with Sunday (0) and ends Saturday (6). |
00 13 * * * /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1pm setiap hari)
00 */2 * * * /usr/local/bin/php /usr/home/abc/xyzt/listCo.php
(setiap 2 jam)
*/30 * * * * /usr/local/bin/php /usr/home/abc/xyzt/listCo.php
(setiap 30minit)
00 01 3 * * /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1am hari ke-3 setiap bulan)
00 01 * * 1-5 /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1am setiap hari isnin-jumaat)
00 01 * 5 * /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1am setaip hari dalam bulan 5 sahaja)
00 01 3 6 * /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1am hari ke-3 dalam bulan 6 sahaja)
00 01 * 8 5-6 /usr/local/bin/php /usr/home/abc/xyz/listCo.php
(1am setiap Jumaat dan Sabtu dalam bulan 8 sahaja)
p/s: Kalau salah info bgtau yer.
RC: Semua benda klu boleh aku nak cronkan. Kalau boleh la. masalanya tak boleh.. waaa...
0 comments:
Post a Comment