Ifoto: esidlangalaleni kwixa elidlulileyo Isifundo esifanelekileyo kwi-cron kunye ne-crontab endicinga ukuba kufanelekile ukuba kwabelwane ngayo. ICron luhlobo olulinganayo neMisebenzi eShedyuliweyo kwiWindows, Kuphela kokuphathwa ukusuka kwisiphelo sendlela. Abo bakhetha ujongano olubonakalayo ukufezekisa injongo efanayo, banokubona oku elinye inqaku. |
Yintoni i-cron?
Igama cron livela kwi Greek chronos elithetha "ixesha" Kwinkqubo yokusebenza ye-Unix, i-cron ngumphathi wenkqubo yesiqhelo (daemon) eqhuba iinkqubo okanye izikripthi rhoqo (umzekelo, yonke iminithi, usuku, iveki, okanye inyanga). Iinkqubo ekufuneka zenziwe kunye nexesha ekufuneka zenziwe ngalo zichaziwe kwifayile ye-crontab.
I sebenza njani
I-cron daemon iqala ukusuka /etc/rc.d/ o / njl njl kuxhomekeke kunikezelo. ICron ibaleka ngasemva, itshekisha itafile yomsebenzi we-crontab umzuzu ngamnye / njl / crontab okanye ngaphakathi / var / spool / ikron kukhangelwa imisebenzi ekufuneka yenziwe. Njengomsebenzisi sinokongeza imiyalelo okanye izikripthi ezinemisebenzi yokwenza izinto ngokuzenzekelayo. Oku kuluncedo umzekelo ukuzenzekelayo ngokuhlaziya inkqubo okanye inkqubo elungileyo yogcino.
Yintoni iCrontab?
ICrontab yifayile yokubhaliweyo elula egcina uluhlu lwemiyalelo ekufuneka yenziwe ngexesha elichazwe ngumsebenzisi. ICrontab iya kujonga umhla kunye nexesha apho kufuneka kwenziwe iskripthi okanye umyalelo, imvume yokuphumeza kwaye iya kuyenza ngasemva. Umsebenzisi ngamnye unokuba nefayile yakhe ye-crontab, enyanisweni / njl / crontab Kucingelwa ukuba yingcambu yomsebenzisi we-crontab file, xa abasebenzisi abaqhelekileyo (kunye nengcambu) bafuna ukuvelisa eyabo ifayile ye-crontab emva koko siya kusebenzisa i-crontab command.
ICrontab yeyona ndlela ilula yokulawula imisebenzi yekron kwiinkqubo ezininzi zabasebenzisi, nokuba ngumsebenzisi wenkqubo elula okanye umsebenzisi wengcambu.
Sebenzisa crontab
Siqala ngomzekelo olula.
Siza kuzenzekelayo ngokuhlaziya inkqubo, ukuphelisa into ecaphukisayo "Ndihlala kufuneka ndihlaziye kwaye andiyithandi loo nto!"
Okokuqala siza kwenza iskripthi. Esi skripthi siza kubizwa ngekron kwaye iya kuba nayo yonke imiyalelo esifuna ukuba siyenze, ke ngoko kuyafuneka ukuba uyivavanye kwiimeko ezininzi kwaye ngeendlela ezininzi ngaphambi kokuyifaka kwikron, iskripthi sokuhlaziya esilula ngolu hlobo:
#! / bin / bash #script yokuhlaziya umzekelo #ukhetha ulwabiwo lwakho # debian-ubuntu # apt-fumana uhlaziyo kunye nokufumana-uphuculo #fedora #yum-uhlaziyo #Arch #pacman -noconfirm -Syu
Susa i # kumgca wakho we-distro. Kwimeko apho Ubuntu / Debian, iqala ngokufumana ngokufanelekileyo.
Sigcina iskripthi njengohlaziyo.sh (umzekelo isikhombisi solawulo kwikhaya lakho). Sitshintsha iimvume zokwenza iskripthi esichaziweyo nge:
chmod a + x ~ / izikripthi / uhlaziyo.sh
Sisebenzisa iskripthi amatyeli aliqela ukuqinisekisa ukuba yonke into ihamba kakuhle, siyiguqula into efunekayo (mayingabinazimpazamo, kungenjalo ikron iyakuphindaphinda impazamo kwakhona). Ngoku ukongeza umsebenzi kwi-crontab yethu.
Yongeza imisebenzi kwi-crontab
Senza ushicilelo lwe-crontab nge-crontab -e, kwezinye ii-distros (ezinje nge-Ubuntu) isinika ithuba lokukhetha umhleli wombhalo esiwufunayo, abanye esisele nabo vi. Ifayile ye-crontab iya kujongeka ngoluhlobo.
# mh dom mon dow umyalelo womsebenzisi
phi:
- m ingqamana nomzuzu wokukhutshelwa kweskripthi, amaxabiso ukusuka ku-0 kuye ku-59
- h Ixesha elichanekileyo, ifomathi yeeyure ezingama-24 iphethwe, amaxabiso aqala ku-0 ukuya ku-23, kunye no-0 ngo-12: 00 ezinzulwini zobusuku.
- dom ubhekisa kumhla wenyanga, umzekelo ungakhankanya i-15 ukuba ufuna ukusebenzisa zonke iintsuku ezili-15
- dow Kuthetha usuku lweveki, linokuba linani (0 kuye ku-7, apho u-0 no-7 bangeCawa) okanye oonobumba abathathu bokuqala bosuku ngesiNgesi: mon, tue, wed, thu, fri, sat, sun.
- umsebenzisi ichaza umsebenzisi oza kwenza lo myalelo, inokuba yingcambu, okanye umsebenzisi owahlukileyo okoko benemvume yokwenza iskripthi.
- umyalelo ubhekisa kumyalelo okanye indlela eyiyo yeskripthi ekufuneka yenziwe, umzekelo: /home/usuario/script/actualizar.sh, ukuba ibiza iskripthi kufuneka senziwe
Ukucaca imizekelo embalwa yemisebenzi yekron echaziweyo:
15 10 * * * umsebenzisi / ikhaya/usuario/script/update.sh
Iya kuqhuba uhlaziyo lweskripthi.sh ngo-10: 15 kusasa yonke imihla
15 22 * * * umsebenzisi / ikhaya/usuario/script/update.sh
Iya kuqhuba uhlaziyo.sh script kwi-10: 15 yonke imihla
00 10 * * 0 ingcambu apt-ufumane-uhlaziye umsebenzisi wengcambu
Iya kuqhuba uhlaziyo rhoqo ngeCawa ngo-10: 00 ekuseni
45 10 * * ingcambu yelanga apt-fumana -ukuhlaziya
Umsebenzisi wengcambu uya kuqhuba uhlaziyo rhoqo ngeCawa (ngeLanga) ngo-10: 45 kusasa
30 7 20 11 * umsebenzisi / ikhaya /usuario/script/updata.sh
Nge-20 kaNovemba ngo-7: 30 umsebenzisi uza kuqhuba iskripthi
I-30 7 11 11 yomsebenzisi welanga /home/usuario/script/pastel_con_velitas.sh
Nge-11 ka-Novemba ngo-7: 30 kusasa kwaye ngeCawa, umsebenzisi uya kubhiyozela i-sysadmin yakhe (Oko kukuthi, ndim)
01 * * * * umsebenzisi / ikhaya/usuario/script/molestorecordatorio.sh
Isikhumbuzo esicaphukisayo umzuzu ngamnye weyure yonke imihla (AKUKHUTHIZWA).
Zingasaphathwa Uluhlu olukhethekileyo:
30 17 * * 1,2,3,4,5
Ngo-5: 30 emva kwemini yonke imihla ukususela ngoMvulo ukuya ngoLwesihlanu.
00 12 1,15,28 * *
Ngentsimbi ye-12 emini ngeyokuqala, ishumi elinesihlanu kunye ne-28th yenyanga nganye (efanelekileyo yokuhlawulwa)
Ukuba oku kuyabhidisa, ukuphatha i-crontab imitya ekhethekileyo yokuchaza ezi zigaba.
@reboot Qalisa kube kanye, ekuqaleni
@yearly isebenza kube kanye ngonyaka: 0 0 1 1 *
@ ngokufanayo no @yearly
@ inyanga ibaleka kube kanye ngenyanga, usuku lokuqala: 0 0 1 * *
@weekly ngeveki umzuzu wokuqala weyure yokuqala yeveki. 0 0 * * 0 ″.
@ imihla ngemihla, ngo-12: 00 AM 0 0 * * *
@midnight efanayo @daily
@ ngeyure kumzuzu wokuqala weyure nganye: 0 * * * *
Ukusetyenziswa kwayo kulula kakhulu.
@hourly user /home/user/script/molestorecordatorio.sh @monthly user /home/user/script/backup.sh @ngcambu yentsuku nganye ufumane uhlaziyo kunye ne-apt-ufumane-uphuculo
Eyokugqibela kodwa engancinananga:
Ulawulo lomsebenzi weCron
crontab ifayile
Faka endaweni yefayile ye-crontab ekhoyo nefayile echazwe ngumsebenzisi
i-crontab -e
Hlela ifayile ye-crontab yomsebenzisi, umgca ngamnye omtsha uya kuba ngumsebenzi omtsha we-crontab.
i-crontab -l
Dwelisa yonke imisebenzi ye-crontab yomsebenzisi
icrontab -d
Cima i-crontab yomsebenzisi
Ikhontrakthi -c dir
Ichaza isikhombisi somsebenzisi somsebenzisi (oku kufuneka kubhalwe kwaye kuphunyezwe iimvume)
crontab -umsebenzisi
isimaphambili sokuphatha i-crontab yomnye umsebenzisi, imizekelo:
$ sudo crontab -l -u ingcambu $ sudo crontab -e umsebenzisi2 #crontab -d -u umsebenzisi
Esi sixhobo, njengabanye abaninzi, sinokubonwa nzulu nangakumbi kwi:
Ugh ... uyabhideka kancinci.
* / 30 ilahlekile (kwicandelo lemizuzu) elibaleka rhoqo kwimizuzu engama-30 ...
Yile nto bendizakuhlomla ngayo ndide ndigqibe kwelokuba ndiphonononge izimvo 😀
Esi siguquli sisiqwenga esibaluleke kakhulu solwazi kunye nento eluncedo kakhulu.
Molo!
Okwangoku ndivavanya ubumbeko rhoqo kwimizuzu engama-45.
* / 45 * * * *, kwaye umyalelo wenziwa kwimizuzu engama-45 yeyure nganye kunye neyure nganye. Koko kukuthi:
Isebenza ngo-3: 45, emva koko ngo-4: 00, 4:45, emva koko ngo-5: 00, 5:45, 6:00, 6:45, njalo njalo.
Ndinokwenza ntoni ukuze ibe kuphela kwimizuzu engama-45, okanye ubuncinci kube kanye kwimizuzu engama-45 ngeyure nganye.
Molo!
Okwangoku ndivavanya ubumbeko rhoqo kwimizuzu engama-45.
* / 45 * * * *, kwaye umyalelo wenziwa kwimizuzu engama-45 yeyure nganye kunye neyure nganye. Koko kukuthi:
Isebenza ngo-3: 45, emva koko ngo-4: 00, 4:45, emva koko ngo-5: 00, 5:45, 6:00, 6:45, njalo njalo.
Ndinokwenza ntoni ukuze ibe kuphela kwimizuzu engama-45, okanye ubuncinci kube kanye kwimizuzu engama-45 ngeyure nganye.
Molo ulwazi oluluncedo kakhulu ukucacisa ukuba isebenza kanjani ikron.
Ii-Byte
ye *
Ukugqwesa, enkosi ngokucacisa ukuba isebenza kanjani ikron .. masibeke isandla kancinci 🙂
Lo mgca njengoko ndiwuqonda uya kwenziwa nge-10: 15 pm, undilungise ukuba andilunganga
Kulungile apho ithi ngo-10: 15 kusasa
15 22 * * * umsebenzisi / ikhaya/usuario/script/update.sh
Molo! Ulwazi oluhle kakhulu.
Ukwenza iSkripthi rhoqo kwisiqingatha seyure, umgca ekufuneka wongezwe kwiCronTab uya kuba ngu: "30 * * * * ingcambu iScrip.sh" ilungile? Enkosi kakhulu!
Hayi. Ukuba ndikhumbula ngokuchanekileyo, kufuneka ubeke / 30 * * * * ingcambu iScrip.sh.
Oko kukuthi, yongeza / ngaphambi kwama-30.
Masinwabe! UPawulos.
Molo ndiyithandile iposti yakho, igqibelele kodwa bendifuna ukukubuza into.
Ndinengxaki ngalo myalelo kwaye omnye unje ngo "at".
Ndifuna ukuqhuba iskripthi ngexesha elithile kwaye ndibeke
-f /home/mi_user/Desk/script.sh 18:08 umzekelo
Iskripthi asenziwanga kwiscreen, oko kukuthi, kwisiphelo sendlela, ngaba siyenziwa ngasemva?
Kwaye kwenzeka into efanayo ngekron, ndihlela ifayile ye-crontab nge "crontab -e"
ekugqibeleni ndongeza lo mgca:
46 19 my_user /home/mi_user/Desk/script.sh
kwaye ayenzi nto, ayibonisi skripthi.
Nasiphi na isiphakamiso? Enkosi kakhulu kwaye ndicela uxolo ngayo nayiphi na inkxamleko
Ukuze i-terminal ibonakale, kuya kufuneka usebenze i-terminal kwaye udlulise iskripthi njengeparitha.
Umzekelo:
lxterminal -e "my_user /home/mi_user/Desktop/script.sh"
Ipharamitha oyisebenzisayo inokwahluka ngokusekwe kwisiphelo sendlela oyisebenzisayo.
Ndiyathemba ukuba iyasebenza.
Wanga! UPawulos.
Igalelo liyaxatyiswa.
Ngama-10 amanqaku !!
salu2!!
Enkosi kakhulu, indincede kakhulu ukucacisa ezinye izinto, enkosi ngokupheleleyo, ngeenkcukacha ezithe kratya okanye imibuzo ndiza kuya kwi-MAN PAGE, ndiphinde ndabulisa.
Malume enkosi kakhulu, kudala ndifunda kwaye ndivavanya imizekelo. enkosi kakhulu ... iyaqondakala. Masinwabe
Ndisebenzise ubuntu Server 12.04.2 LTS, kunye nohlobo lwe-crontab endinayo, ukucima uluhlu lwemisebenzi yomsebenzisi esetyenzisiweyo, crontab -r (kunye -l, njengoko le ncwadana isitsho). Ngokuqinisekileyo ngumbuzo weenguqulelo.
Kwelinye icala, ndakhe ndasebenza i-crontab kuphela kwaye olu hlobo mandenze eyam ifayile yokuphumeza, kodwa ayisiyiyo leya yayisenziwa. Eminye ibalekayo yile kwi / etc / crontab. mhlawumbi umntu uza kusebenzisa uluvo.
I-PS (ndikhangele ndifumana indawo kunye nalapho i-crontab kodwa ibuyisa kuphela idilesi ekhankanyiweyo kunye nenye ifayile ebhalwe ngokufihlakeleyo, ke ukuba umntu owenzekileyo ibinguye / etc / crontab, kodwa xa kusenziwa umthetho we-crontab -e, eyam yavela ngayo yonke imisebenzi ebendiyichazile) le fayile ibigcinwa phi '???? Imibuliso. Ndihlala ndingena ngeengcambu.
Zintle, ziluncedo kakhulu !!!
Molo, ndingathanda ukwenza oku …………………………………
Oko kukuthi, ngexesha elithile ikhadi lothungelwano liyacinywa …………, ndilibeke kwikhontrakthi kwaye alisebenzi …… .. kwenzeka ntoni?
Ukubulisa nokubulela
Uphose ukuchaza u "mon" emva kwesihloko "Yongeza imisebenzi kwi-crontab"
Inqaku lisemnandi, ikron iluncedo kakhulu.
Yayipholile kangakanani le post intle, ndibuze
Ukuba ndifuna ukugcina umkhondo weerekhodi ezishiyiweyo ngokwenza imisebenzi, ndingazibona phi?
kukuthatha isigqibo sokuba ndifuna ukubona imbali yezenzo ezenziweyo ngaphambili kule fayile kwaye ndifuna ukubona ukuba ngubani oyiguqulileyo kunye nomhla
I gracias
Ndifuna ukujonga imbali yokuguqulwa kwale
ndingayenza njani
I gracias
Kulungile kusasa,
Ndicinga ukuba kwiskripthi sobuntu wenze impazamo, ubeke i-ap-get -y upgrade endaweni ye-apt-get -y upgrade. (Ushiye i t).
A ubingelele.
Kunjalo. Enkosi!
Wanga! UPawulos
Ndifuna ukwazi ukuba ndiyenza njani ifayile yekron ukuze ndikwazi ukukhankanya ixesha ngalinye xa kusenziwa, isikhombisi, njl.
Enkosi ngokucacisa ukusebenza kunye nemiyalelo esisiseko yekron, ngoku ukuzonwabisa okwethutyana.
Nanini na xa ndikhangela ulwazi kuso nasiphi na isihloko esimalunga neGnu / Linux, ndiyajikeleza kwaye ndihlala ndifumana ama-90% amatyala sesona sifundo silungileyo kolu luntu lukhulu, ndicinga ukuba ukusukela ngoku ndiza kuqala apha ukuya kwenye indawo.
Phendula nge quote
Enkosi Sander! Ihagi! UPawulos.
dom = usuku lwenyanga
dow = usuku lweveki
kulula xa unxulumana
Enkosi kakhulu, ugqibelele kwaye uchaze kakuhle.
Yile nto inye asinike yona utitshala weeNkqubo eziSebenzayo, anditshintshi kwanto, ngoku ndiyabona ukuba kutheni iklasi imbi kangaka.
Uqikelelo,
Umbuzo, ngaba ixesha lomsebenzi linokulinganiselwa?
Umzekelo ndinomsebenzi ophinda yonke imizuzu emi-5, uphindaphindo ukuba loo msebenzi usasebenza, bulala kwaye uphinde usebenze.
Siyabonga,
UMarcelo.
Molo, Marcelo!
Ndicinga ukuba kungangcono xa uphakamisa lo mbuzo kwinkonzo yethu yemibuzo neempendulo ebizwa Buza kuLinux ukuze uluntu lonke lunokukunceda kule ngxaki yakho.
Ukwanga, uPablo.
iposti entle.
Nguwuphi umyalelo kwisiphelo sendlela yokongeza imisebenzi kwi-crontab (ngaphandle kokungena kwi-crontab kwaye uyongeze ngesandla nge-'crontab -e 'okanye ubeke endaweni ye-crontab ngenye crontab ene' crontab fayile ').
Umbono kukwenza iskripthi sangaphandle ukongeza imisebenzi kwi-crontab
Gracias
Ndicinga ukuba ungasebenzisa u "echo" nantoni na ofuna ukuyongeza '| ikati >> 'cronotab indlela (/ njl / cronotab)' «
Ibinzana lingasebenza njani rhoqo kwiintsuku ezi-3 ngokuchanekileyo
Sawubona!
Ndinengxaki yokuphumeza umsebenzi wekron.
Ndiqhuba lo msebenzi ulandelayo nge-cronta -e:
01 * * * * ingcambu / indlu/user/script/mfile.sh
kodwa umsebenzi awugqitywanga. Ndijongile ukuba i-myfile.sh inayo imvume yokuphumeza kwaye umsebenzisi oyiphumezayo yingcambu.
Ndibaleka umsebenzi ofanayo kwi / etc / crontab kwaye emva kokuqalisa inkonzo kwakhona, ayisebenzi kum.
Umxholo we myfile.sh ngumyalelo ohlaziya i-DB kwaye ukuba ndiyayiqhuba kwikhonsoli iyasebenza.
naluphi na uluvo lokuba ingaba yintoni ingxaki?
Kungenzeka ukuba umsebenzisi wedatha akanazo zonke iimvume kwaye kuya kufuneka kuqala uthumele izinto eziguquguqukayo kokusingqongileyo kwiinjini yakho yedatha.
Umzekelo kwi-db2 lo mgca ungaya ekuqaleni kweskripthi
. / ikhaya / db2inst1 / sqllib / db2profile
Esinye isizathu sinokuba iskripthi sifuna uqhagamshelo kwindawo yogcino lwedatha, yenza uqhagamshelo kwiziko ledatha ngaphakathi kwiskripthi
Bendingazi ukuba kufuneka ndiyiqale kwakhona i-crond, bendikhe ndalwa nale nto okwexeshana
Bayayazi indlela yokubonisa ukuba umsebenzi wenziwa qho ekupheleni kwenyanga, ngexesha elibonisiweyo .. inkcukacha kukuba andinakufezekisa indlela endazi ngayo ukuba ithatha usuku lokugqibela lwenyanga nganye .. ??? Kwafuneka ndizibhale phantsi nganye nganye kodwa xa kuphela inyanga kaFebruwari ifikile ukuba ibicicio iyanzima kum ..
Usuku olumnwandi!!
Ndiyimisa njani inkqubo eqhutywa kwi-crontab?
inkqubo * …………
Ngaba kunokwenzeka ukuba ungandinceda? Isikripthi se-e tenho um ngu-minha esibhaliweyo esingasebenziyo akukho crontab! jб dei zonke iimvume, akukho cron yabucala okanye umsebenzisi onokuyenza-akukho nto yenzekayo! Ndingathanda ukwazi ukuba ungandinceda, ezinye izinto azisebenzi akukho cron! Vlws
Ungawubeka njani umsebenzi wokuqhuba yonke imihla yokugqibela yenyanga (iintsuku: 31-30-28)?
Njengoko sele uyazi, lo su usetyenziselwa ukutshintsha umsebenzisi kwikhonsoli. Ukuba ndisebenzisa lo myalelo su ngale ndlela: "umsebenzisi" utshintshe umsebenzisi kodwa ngaphandle kwezicwangciso ezifanelekileyo "zomsebenzisi", ukuba ndiqhuba su njengo: "su - umsebenzisi" utshintshe umsebenzisi ngokulayisha useto lomsebenzisi. Ngekron ndibonisa umsebenzisi, kodwa ndizilayisha njani iisetingi zalo msebenzisi?
Kwaye ukuba ndifuna ukuyiyeka?
Sawubona,
Andazi ukuba ndenza into engalunganga, kodwa ndilandela amanyathelo kwaye akukho nto iyenziwayo. Ndizamile:
59 * * * * / usr / bin / gedit
* * * * * / usr / bin / gedit
* * * * * ingcambu / usr / bin / gedit
* * * * * usr / bin / test.sh
* * * * * ingcambu usr / bin / test.sh
kwaye akukho nto konke konke. Ayenzi nto. Ndibuyisele kwakhona nayo yonke into.
imuchas Gracias