Ubuntu Cronjob: selgitus ja seadistamine
Ubuntu kasulik tööriist on nn cron-tööd. Selgitame, kuidas seda seadistada ja kasutada.
Ubuntu cronjob - mis see on?
- Cron-töö - mida nimetatakse ka crontabiks - on käsk, mis käivitab skriptid ja programmid kindlaksmääratud ajal. Seetõttu sobib see näiteks varukoopiate tegemiseks või värskenduste tegemiseks.
- Pange siiski tähele, et cron-tööd teostatakse ainult siis, kui teie arvuti on tõesti sisse lülitatud. Kadunud cron töökohti ei korvata.
- Cronjob koosneb 7 osast. Esimene tähistab minutit ja teine tundi, mille jooksul ülesanne on täidetud. Kolmas jaotis sisaldab kuu päeva ja neljas on kuu ise. Viies on nädalapäev, arvud 0 ja 7 tähistavad pühapäeva. Kuues osa loetleb kasutaja, kelle jaoks cronjobit teostatakse. Lõpuks märgitakse ülesanne ise.
- Croni töökohad salvestatakse kogu süsteemis kataloogis "/ etc / crontab" või üksikute kasutajate jaoks kataloogis "/ var / spool / cron / crontabs".
Loo Ubuntu cronjob - just nii see ka tehtud on
- Terminali cronjob-teenus on juba Ubuntu lisatud. Seetõttu pole paigaldamine vajalik.
- Cron-töö loomiseks või muutmiseks avage terminal ja tippige "crontab -e". Kui soovite redigeerida mõne teise kasutaja cron-töid, sisestage "crontab -u user -e" ja asendage "user" soovitud kasutajaga.
- Nüüd saate valida, millist redigeerijat soovite croni tööde redigeerimiseks kasutada. Soovitame kasutada nanot, kuna see on lihtsaim viis.
- Nooleklahvide abil saate liikuda dokumendi allserva ja sisestada oma kronjob. Kui te parameetrit ei vaja, täitke see lihtsalt tähega "*". Näiteks kui soovite iga päev kella 13.30 ajal teha kronotööd, peate täitma ainult tunnid ja minutid, ülejäänud väärtuste asemel on "*".
- Kui olete lõpetanud, vajutage samaaegselt [Ctrl] ja [X] ning kinnitage klahvidega [J] ja [Enter]. Teie muudatused salvestatakse ja suletakse nano.
- Kõigi oma cron-tööde loetlemiseks tippige käsk "crontab -l". Teise kasutaja cron-tööde nägemiseks tippige "crontab -u user -l". Asendage "kasutaja" soovitud kasutaja nimega.