Iyi ndiyo chinyorwa chechipiri kubva munhevedzano yatinoshandisa rondedzero yezvinonzi neChechi yeRoma "zvivi zvinouraya" sechikonzero cZiva zvakawanda nezve mirairo uye zvirongwa zveLinux world. Muchiitiko ichi tinoenderera mberi tichitaura nezvekushandiswa kwecron iyo ichave yakakosha kune avo vanorima usimbe.
Tichifunga kuti tiri kurarama munguva yevanhu vari nyore kugumbura, regai ndijekese, ndisati ndapinda munyaya yacho, kuti haisi vavariro yangu kuseka zvitendero zvechitendero zvomumwe munhu. Chero zvazvingava, kuzvinyomba. Ndakapedza chikamu chikuru chemaXNUMX ndichidzidza katekisimo kuitira kuti mushure mekutora Chirairo changu chekutanga handina kuzombotsika tsoka zvakare muchechi kunze kwekunge pane chiitiko chemhuri chaichida. Ndinofanira kudzorera nguva iyoyo neimwe nzira.
Chii chinonzi cron uye crontab?
Isu takanga tati cron idhimoni, kureva chirongwa chinomhanya kumashure pasina kupindira kwemushandisi. Ndichitsvaga rumwe ruzivo rwechinyorwa ichi, ndakaona kuti kushandura daemon (Nzira iyo Unix masisitimu uye zvinobva painodaidza rudzi urwu rwechirongwa) sekuti daemon iri kukanganisa kwakaparariraasi handisi kuzozvigadzirisa. Tiri kutaura nezvezvivi, panofanira kunge paine dhimoni rimwechete.
Basa recron nderekuita, pane imwe nguva yakatarwa, rimwe basa. Nguva zhinji imhaka yezvido zvehurongwa, kunyangwe vashandisi vanogona kuratidza vamwe nekugadzirisa faira remavara rinozivikanwa secrontab.
Mune yapfuura positi takanga tataura kuti mirairo yekugadzira crontab ndeiyi:
crontab –e
kune iyo default mushandisi
O
crontab –u nombre_de_usuario
kune chero chevamwe.
Crontab ifaira remavara rinopa Cron mirairo pane zvekuita uye nguva yekuzviita.
Nezve kushandisa cron kuburikidza necrontab
Kugadzira yedu crontab isu tinofanira kufunga zvinotevera:
- Mutsetse mumwe unoshandiswa pabasa rega rega.
- Zuva uye nguva yekuitwa kwebasa inofanira kuratidzwa. Kana iri basa rinoda periodicity. Semuenzaniso, Chitatu chega chega na5 am, mamwe maparamita anotsiviwa neasterisks (*).
- Kana iwe uchida kupa huwandu hunopfuura humwe hunokosha hweparameter yakapiwa, kukosha kwega kwega kunofanira kuparadzaniswa necomma.
- Parameters inoparadzaniswa nenzvimbo.
- Iyo dhairekitori panowanikwa command launch inofanira kuzivikanwa
Somuenzaniso, kana tichida kuti kombiyuta yevana vedu izime zuva nezuva na20:XNUMX p.m., murayiridzo waizova
0 20 * * * /sbin/shutdown
Kana tichida kuti kuvharwa kuve neSvondo chete, isu tinoshandura rairo kuti
0 20 * * 0 /sbin/shutdown
Pane mamwe mapfupi anotiponesa kubva pakutonyora ese ma parameter. Vari:
- @hourly: Ita murairo paawa o'clock.
- @zuva nezuva: Mhanya murairo pakutanga kwezuva rimwe nerimwe.
- @weekly: Isai murairo pakutanga kwezuva rokutanga revhiki.
- @monthly: Uite murayiro pakutanga kwezuva rokutanga romwedzi mumwe nomumwe.
- @gore: Ita murairo muminiti yekutanga yegore.
Mimwe mienzaniso yekushandisa murairo uyu ndeiyi:
@daily /bin/sh /ruta_al_script/nombre_del_script.sh
mhanyisa Bash script.
@hourly /bin/python3 /ruta_al_script/nombre_del_script.py
mhanyisa python script awa yega yega.
Muzviitiko zvese zvinyorwa zvinofanirwa kunge zvine mvumo yekuita.
Mumienzaniso yatakaona, kwete chete murairo unoratidzwa, asiwo nzira iyo inozoitwa iripo. Isu tichashanda nemadhairekitori aya:
- /bhini: Iyo ine zvese zvikumbiro zvinodiwa pakushanda kweiyo system.
- /sbin: Heano maapplication anodiwa nemudzi mushandisi kubata sisitimu.
- / kumba: Kunochengeterwa maapplication emushandisi wega wega.
- /usr: Zvishandiso uye mafaera akaiswa nevashandisi anochengetwa pano. Zvinosanganisira mafaera ane mazita uye mabasa akataurwa mune ino runyorwa.
Muchinyorwa chinotevera tichaona maitiro ekuvandudza crontab kunyora uye mamwe otomatiki maturusi anowanikwa kuLinux.