What is Cron Job?


Cron job ဆိုတာက linux  server ေတြမွာ အခ်ိန္ နဲ႔လိုက္ျပီး script တစ္ခုကို သတ္မွတ္အခ်ိန္တိုင္း run ေနေစလိုတဲ႔ အခါမွာ သံုးၾကပါတယ္။
ဥပမာ။   ။  တစ္ပတ္တစ္ၾကိမ္ customer ေတြဆီကို email ေတြပို႔ခ်င္တဲ႔အခါ
                 တစ္လ တစ္ၾကိမ္ register လုပ္ျပီး approve မလုပ္ထားတာေတြကို ဖ်က္ခ်င္တဲ႔အခါ
                 သံုးလို႔ရပါတယ္။

cron job ကို setup လုပ္ဖို႔ crontab command  သံုးျပီး လုပ္လို႔ရပါတယ္။
Hosting server ေတြမွာေတာ႔ မတူညီတဲ႔ ပံုစံနဲ႔ အသံုးျပဳ လို႔၇ပါတယ္။command line နဲ႔ သံုးမည့္သူအတြက္သာ crontab command က သံုးရမွာျဖစ္ပါတယ္။

crontab -e လို႔ရိုက္လိုက္ရင္ cron job ေတြေရးဖို႔ file တစ္ခုပြင့္လာမွာျဖစ္ပါတယ္။အဲဒီအခါ ေအာက္ပါ cron format အတုိင္း ေရးထည့္လိုက္ရင္ ရပါျပီ။

Cron ၇ဲ႔ format က
MIN HOUR DOM MON DOW CMD
 
Field Description Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command Any command to be executed.
 
reference from http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/ 
 
 

30 08 10 06 * /home/ramesh/full-backup
6 လပိုင္း 10 ရက္ေန႔ 8 နာရီ ၃၀ မိနစ္မွာ full-backup script file ကို run ဖို႔ ေရးထားတာပါ။


00 09-18 * * 1-5 /home/ramesh/bin/check-db-status
တနလၤာေန႔ကေန ေသာၾကာေန႔အထိ ေန႔တိုင္း ၉ နာရီကေန ၁၈ နာရီအထိ တစ္နာရီတစ္ခါ run ေပးမွာပါ။ 



 
Previous
Next Post »

Thorium School

Thorium School
Be professional with us