Konfiguracija anacrona
Postano: 19 stu 2016, 23:54
...da li netko ima iskustva sa konfiguracijom anacron-a (anacrontab)?
Imam ja. Što te muči? Nisam neki ekspert, ali uspješno sam ga koristila.trzalica je napisao/la:...da li netko ima iskustva sa konfiguracijom anacron-a (anacrontab)?
Kod: Označi sve
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
Kod: Označi sve
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 4 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthlyKod: Označi sve
#!/bin/sh
rm [NAZIV FAJLE]Kod: Označi sve
7 4 [naziv] bash [lokacija skripte]Kod: Označi sve
anacron -s -f -nZa razliku od njega, cron ti je stalno pokrenut u pozadini i "pazi" kad se treba nešto izvršiti. Međutim, njegov problem je to što ako ti je komp ugašen u vrijeme kad bi se neki task trebao izvršiti, cron neće to "zapamtiti" i napraviti kad se ponovno podigne sustav. U osnovi, preskočit će taj jedan task.It's not a resident daemon and therefore can't replace crond or atd; it starts up at boot time (or when manually invoked), waits for the appropriate intervals before checking some conditions, and then once everything has been checked or run, it quits.
Kod: Označi sve
crontab -eTo je vjerojatno jednostavna skripta za brisanje, ali možda joj nešto nedostaje od ovih stvari navedenih gore, pa ju zato cron ne može pokrenuti. I naravno, skripta bi trebala imati pravilno postavljene permissione i biti executable.When cron job is run from the users crontab it is executed as that user. It does not however source any files in the users home directory like their .cshrc or .bashrc or any other file. If you need cron to source (read) any file that your script will need you should do it from the script cron is calling.
If the users account has a crontab but no usable shell in /etc/passwd then the cronjob will not run. You will have to give the account a shell for the crontab to run.
If your cronjobs are not running check if the cron daemon is running. Then remember to check /etc/cron.allow and /etc/cron.deny files. If they exist then the user you want to be able to run jobs must be in /etc/cron.allow. You also might want to check if the /etc/security/access.conf file exists. You might need to add your user in there.
Crontab is not parsed for environmental substitutions. You can not use things like $PATH, $HOME, or ~/sbin. You can set things like MAILTO= or PATH= and other environment variables the /bin/sh shell uses.
Znam-znam, zato i želim anacron a ne cron za ovaj zadatak. Cron sam do sada uspješno konfigurirao po serverima samo sa anacronom nisam imao iskustva.Problem je što ti anacron ne funkcionira isto kao cron:
It's not a resident daemon and therefore can't replace crond or atd; it starts up at boot time (or when manually invoked), waits for the appropriate intervals before checking some conditions, and then once everything has been checked or run, it quits.
Za razliku od njega, cron ti je stalno pokrenut u pozadini i "pazi" kad se treba nešto izvršiti. Međutim, njegov problem je to što ako ti je komp ugašen u vrijeme kad bi se neki task trebao izvršiti, cron neće to "zapamtiti" i napraviti kad se ponovno podigne sustav. U osnovi, preskočit će taj jedan task.
Za ovaj tvoj slučaj možeš probati kombinirati @weekly i @reboot opcije u samom crontabu. Pritom ne bi trebao uređivati crontab u text editoru, već koristiti naredbu
. Ili, možeš samo definirati taj @weekly u crontabu i onda symlinkati skriptu u /etc/cron.weekly - onda bi ju anacron trebao pokrenuti ako ju cron "propusti".Kod: Označi sve
crontab -e
U anacrontab sam dodao:Ne možeš u anacrontabu pisati "bash", mislim da mora biti eksplicitna putanja do svake naredbe.
7 4 job_identifier /bin/sh /putanja/do/skripte
Kod: Označi sve
7 4 [naziv] /bin/sh [putanja do skripte]Kod: Označi sve
sudo anacron -s -f -n
Da, sada radi tj. testirao sam sa:Abzeenth je napisao/la:OK, dakle sad radi? Super![]()
Evo, odvojila sam postove u zasebnu temu.
Kod: Označi sve
sudo anacron -s -f -n