Cron ให้คุณรัน commands, programs, และ scripts อัตโนมัติที่ defined points in time หรือ on a schedule มัน powerful, light, และยากที่จะ wrap your head around นั่นคือเหตุผลที่คุณหา front-ends ที่พยายาม simplify การใช้ crontab ได้ และ Zeit เป็นหนึ่งใน best ones
Zeit's sole goal คือทำให้ adding และ managing cron jobs ของคุณ very easy ด้วย Zeit การรัน commands และ scripts straightforward เท่ากับการเพิ่ม new entry ไป task list มาดูว่ามันให้คุณสร้าง cron jobs ใน Linux ได้ง่ายอย่างไร
การติดตั้ง (Installation)
บน most Linux distributions จะต้อง build Zeit from source หลัง download และตาม official documentation สร้าง usable app ได้ด้วย:
mkdir build && cd build cmake .. make -j2 ./src/zeit
หากอยู่บน Ubuntu สามารถเพิ่ม repository และติดตั้ง Zeit ด้วยคำสั่งต่อไปนี้:
sudo add-apt-repository ppa:blaze/main sudo apt update sudo apt install zeit
หลังจากสักครู่ จะหา Zeit ใน installed programs ได้ Locate และรัน app
Tasks และ Schedules
Zeit's interface straightforward เพื่อเพิ่ม task คลิกปุ่ม "Add Task"
ใส่ชื่อ task ใน Description field พิมพ์ command ที่ต้องการ schedule ใน Command field
ใน section "Time and Date" เลือก Basic ซึ่งให้ quickly schedule task รันบน regular pattern สำหรับ customization มากกว่า เลือก Advanced option
Advanced option ให้ input precisely minute, hour, day, day of the week, และ month ที่ task จะรัน All fields populated initially with an asterisk ซึ่งทำงานเป็น wildcard แปลว่า "every" ตัวอย่าง หากใส่ "*" ใน Day field หมายถึง "every day"
สามารถ input more than one number แยกด้วย commas ตัวอย่าง หากใส่ "20, 23" ใน Hour field และ "35" ใน Minute field task จะรันที่ 20:35 และ 23:35 ทุกวัน
หากเคยต้องการ reminder ของ crontab syntax วาง mouse hover over one of the fields Zeit จะแสดง useful pop-up พร้อม examples of how you can set up the task's schedule
หลังสร้าง task แล้ว จะปรากฏใน main list ของ Zeit หากต้องการ disable task เร็ว double-click บนมัน right-click จะ allow edit หรือ remove entirely
Alarms และ Timers
Zeit ให้ตั้ง Alarms และ Timers ได้ แต่เราจะไม่รายละเอียดวิธีทำ เพราะมัน even simpler than tasks ด้วย Alarms และ Timers ไม่ต้องกังวล wildcards และ complicated schedules เพราะ even if it would be useful for some ไม่มี such functionality offered
สามารถตั้ง simple schedules เท่านั้น กำหนด time และเลือก days เมื่อ Alarm หรือ Timer จะรัน แค่นั้นแหละ มี extra buttons สองตัวให้ input current time ใน Hour และ Minutes fields (Now button) หรือ clear them (Reset button) ต้องใช้สองปุ่มที่มี folder icons ถัดจาก Player และ Sound File เพื่อเลือก media player และ sound file ตอนตั้ง alarms และ timers เนื่องจาก Zeit/crontab ไม่มีทาง notify คุณโดยไม่มีพวกมัน มันก็ไม่ allow set up rule with those fields being blank
Control Everything (ควบคุมทุกอย่าง)
ด้วย Zeit คุณ edit your own crontab rules by default active only for your user account เพื่อดู all rules (by others และ system) และ edit everything เปิด "System Mode" จาก View menu
ด้วย System Mode คุณสามารถ tweak existing rules เช่น automated reports ที่ Ubuntu สร้างสำหรับ OS ของคุณ ระมัดระวังมากตอน tweak such rules และจำไว้ว่า changes ที่ทำอาจ break stuff อาจถูก overwrite หลัง software update
Filter และ Find (กรองและค้นหา)
หากพยายาม locate particular rule ใช้ search feature แทนการ scroll up and down the list กด Ctrl + F search field จะปรากฏที่ bottom of Zeit's window ใส่ search term เพื่อหา task ที่ต้องการ
ตอนนี้คุณรู้วิธีใช้ Zeit สร้าง cron jobs ใน Linux แล้ว คุณจะใช้ crontab ทำดีให้ระบบ automated? หรือใช้ systemd as a cron replacement ก็ได้