Yadda za a ajiye lokaci tare da cron: Jagorar jagora da samfurin lambobin

Mataki na ashirin da ya rubuta ta:
  • Jagoran Gida
  • An sabunta: Mayu 09, 2019

Mene ne cron?

Cron ne Linux / UNIX daemon da aka tsara don aiwatar da umurnin a lokacin da aka riga aka saita. Tun lokacin da cron ya kasance wani doki, da zarar an kashe shi bazai buƙatar wani gwamnati daga mai amfani ba. Cron yana sarrafawa ta hanyar saiti na fayiloli da ake kira "cronfiles", a ƙasa shi ne jerin umurnan cron na kowa.

Crontab filename Shigar filename a matsayin fayil ɗinku na crontab.
crontab -eShirya fayil ɗinku na crontab.
crontab -lNuna fayil din crontab.
crontab -rCire fayil dinku na crontab.
[Email kare]Emails da fitarwa zuwa adireshin da aka adana.

Kowace shigarwa cikin fayil crontab zai kunshi waɗannan wurare guda shida waɗanda suka rabu. An tsara tsari na filayen tare da taƙaitaccen bayanin kowane ɗayan a ƙasa.
(s) hour (s) wata (s) wata (s) ranar mako (s) umurnin (s) umurnin (s)

Fielddarajardescription
minute0-59Ya bayyana ainihin minti da umurnin zai kashe.
Sa'a0-23Ma'anar sa'a na rana umarnin zai kashe.
Rana1-31Ya bayyana ranar watan wata umarni zai kashe.
Watan1-12Ma'anar watan shekara ta umarni zai kashe.
Weekday0-6Ƙayyadar ranar mako shine umurnin zai kashe.
Lahadi = 0, Litinin = 1, Talata = 2, Laraba = 3, Alhamis = 4, Jumma'a = 5, Asabar = 6
umurninSpecialDokar da za a kashe.

Hakanan zaka iya amfani da * a maimakon nau'in lambobi na filayen biyar na farko don nuna duk halaye na shari'a. Alal misali, umurnin 0 0 * * 1, zai gudana rubutun a kowane Litinin.
Mafi yawan wannan ɓangaren yana da dacewa kawai idan kuna aiki da rubutattun kalmomi daga madaidaicin umarni a Linux / UNIX, idan kuna amfani da cPanel don Allah a duba "Ta yaya nake tafiyar da rubutun cron daga ɓangaren cPanel" na.

Ta yaya zan iya ajiye lokaci tare da cron?

Akwai hanyoyi da dama da zaka iya amfani da cron don ajiye wasu amma ni da ayyukan da ya fi dacewa da za ka iya tsara shi ne tushen bayanai da kuma shafukan yanar gizon yanar gizo. Ana iya yin waɗannan ayyuka guda biyu da hannu amma suna dubawa akai-akai. Tare da cron za ka iya saita su sau ɗaya kuma san shi za a yi.

Da ke ƙasa akwai rubutun samfurori da zaka iya amfani da su don saita wannan aikin tare da cron.

Shafukan yanar gizo na Ajiyayyen Yanar Gizo (Rubutun da aka bayar Ubuntu)

#! / bin / sh

####################

#

# Ajiyayyen zuwa rubutun NFS.

#

####################

# Abin da za a madadin.

backup_files = "/ gida / var / spool / mail / sauransu / tushen / taya / fita"

# A ina zuwa madadin zuwa.

ƙaddara = "/ mnt / madadin"

# Create archive filename.

rana = $ (kwanan wata +% A)

hostname = $ (sunan mai masauki -s)

archive_file = "$ hostname- $ day.tgz"

# Shigar da sakon matsayi na farko.

echo "Backing up $ backup_files to $ dest / $ archive_file"

date

Kira

# Ajiyayyen fayiloli ta amfani da tar.

tar czf $ rabo / $ archive_file $ backup_files

# Sakon saƙon matsayi na ƙarshe.

Kira

Kira "Ajiyayyen ya gama"

date

# Tsarin jerin fayiloli a $ adadin don duba manyan fayiloli.

ls -lh $ rabo

Bayanin Ajiyayyen Bayanan Manhaja na atomatik (Rubutun da Tamba2.org.uk ya bayar)

#Set da zaɓin 4
#Replace abin da ke BAYAN da = tare da bayanin daga fayil ɗin wp-config.php

DBNAME = DB_NAME

DBPASS = DB_PASSWORD

DBUSER = DB_USER

#Goye "kewaye da adireshinku
EMAIL = "[Email kare]_email.com "

mysqldump -opt -u $ DBUSER -p $ DBPASS $ DBNAME> backup.sql
gzip backup.sql
DATE = "kwanan wata +% Y% m% d`; mv backup.sql.gz $ DBNAME-madadin- $ DATE.sql.gz
echo 'Blog Name: your MySQL Ajiyayyen an haɗe shi' | $tB-$ $ $ DBNAME- madadin- $ DATE.sql.gz $ EMAIL -s “MySQL Ajiyayyen”
rm $ DBNAME-madadin- $ DATE.sql.gz

* Laifi: Ba mu da alhakin idan rubutun ba zai yi daidai ba ko kuma idan ka saita shi kuskure. Idan kana da wasu tambayoyi ko damuwa game da rubutun ko kuma yadda za a kafa shi mafi kyawun lambar sadarwa zai kasance naka mai ba da sabis.

Yaya zan sa wani cron rubutun daga cPanel?

1. Shiga cikin ku cPanlel

2. Nemo wurin "cron jobs" icon (Wannan shi ne gaba daya a cikin sashen ci gaba).

3. Shigar da adireshin E-Mail idan kuna son kwafin kayan aikin gona don a aika muku.

4. Zabi a lokacin da kake son rubutun cron ɗinku don gudu. (Zaɓin wani abu daga "Hakanan Saiti" jerin zaɓuka za su cika filin a gare ku.)

5. Shigar da hanyar rubutun da kake son gudu. (Lura: Kuna buƙatar shigar da fayil ɗin rubutun zuwa ga uwar garkenka, don ƙarin bayani don Allah a duba ƙasa - "Yaya zan shigar da fayil na rubutun" don ƙarin bayani.)

6. Danna "Ƙara sabon Cron Ayuba"

7. Ya kamata a sanya aikinku na cron a yanzu a ƙarƙashin "Ayyukan Cron na yanzu".

Yaya zan shigar da fayil na rubutun?

  1. Daga cPanel zaɓa "Mai sarrafa fayil"
  2. Next zabi "Shafin Farko" sa'an nan kuma danna "Go"
  3. Yanzu zabi "Shiga".
  4. Saita Izininku na Jirgin zuwa 755
  5. Danna "Duba"
  6. Browse zuwa babban fayil wanda ke da rubutun ka kuma danna kan shi, sannan ka danna "Buɗe".

Lura: CPanel naka zai iya saita sabanin wanda aka nuna a sama amma dukan ra'ayoyin ya kamata ya zama daidai.

Game da WASR Guest

Wannan labarin an rubuta shi ta baki mai ba da gudummawa. Lurarrun marubucin da ke ƙasa suna gaba ɗaya ne kuma bazai iya yin tunani da ra'ayi na WHSR ba.

n »¯