วิธีตั้ง crontab ใน Ubuntu

หามาตั้งนาน วิธีตั้ง crontab ให้ sync เวลาจาก Time Server
มาให้กับ web apps server ต้องขอขอบคุณคุณผดุงศิลป์ JI

$ sudo nano /etc/crontab


# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.


SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin


# m h dom mon dow user  command
1 * * * * root ntpdate 192.168.xx.xx //เพิ่มใหม่เข้ามา IP เป็นของ Time Server นะครับ
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Save แล้ว ออก
Ctrl+X ตอบ Y

ดู log
$ sudo tail -f /var/log/syslog
ตัวอย่าง
$ sudo tail -f /var/log/syslog
Jan 12 18:01:01 VLWeb CRON[8998]: (CRON) error (grandchild #9000 failed with exit status 127)
Jan 12 18:01:01 VLWeb CRON[8998]: (CRON) info (No MTA installed, discarding output)
Jan 12 18:05:01 VLWeb CRON[9004]: (root) CMD (ntpdate 192.168.10.12)
Jan 12 18:05:01 VLWeb CRON[9002]: (CRON) error (grandchild #9004 failed with exit status 127)
Jan 12 18:05:01 VLWeb CRON[9002]: (CRON) info (No MTA installed, discarding output)
Jan 12 18:09:01 VLWeb CRON[9007]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm)
Jan 12 18:09:01 VLWeb CRON[9005]: (CRON) info (No MTA installed, discarding output)
Jan 12 18:17:01 VLWeb CRON[9015]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jan 12 18:25:01 VLWeb cron[757]: (*system*) RELOAD (/etc/crontab)
Jan 12 18:27:01 VLWeb cron[757]: (*system*) RELOAD (/etc/crontab)





ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

วิธีแก้ปัญหา putty เป็นภาษาต่างดาวหรือเครื่องหมาย ???

ประวัติต้นแดง

แก้ปัญหา Directory Index เป็นภาษาต่างดาว