cron
è il demone responsabile dell'esecuzione di comandi pianificati e ricorrenti (ogni giorno, ogni settimana, ecc.); atd
è quello che si occupa dei comandi da eseguire una sola volta, ma in un determinato momento nel futuro.
locate
;
crontab -e
(il suo contenuto è memorizzato nel file /var/spool/cron/crontab/utente
).
/etc/crontab
, o scrivere file crontab supplementari nella directory /etc/cron.d
. Queste ultime due soluzioni presentano il vantaggio di essere in grado di specificare l'identità dell'utente da usare quando si esegue il comando.
/etc/cron.hourly/
una volta ogni ora;
/etc/cron.daily/
una volta al giorno;
/etc/cron.weekly/
una volta a settimana;
/etc/cron.monthly/
una volta al mese.
Sun
, Mon
, ecc.);
/etc/crontab
e nei frammenti situati in /etc/cron.d/
, ma non nei file crontab degli utenti);
a-b
descrive l'intervallo di tutti i valori tra a
e b
. La sintassi a-b/c
descrive l'intervallo con un incremento c
(esempio: 0-10/2
significa 0,2,4,6,8,10
). Un asterisco *
è un carattere jolly che rappresenta tutti i possibili valori.
Esempio 9.2. Esempio di file crontab
#Formato #min ora gior mes g-sett comando # Scaricare i dati ogni sera alle 19.25 25 19 * * * $HOME/bin/get.pl # 8.00, nei giorni lavorativi (da lunedì a venerdì) 00 08 * * 1-5 $HOME/bin/faiqualcosa # Riavviare il proxy IRC dopo ogni riavvio @reboot /usr/bin/dircproxy
at
executes a command at a specified moment in the future. It takes the desired time and date as command-line parameters, and the command to be executed in its standard input. The command will be executed as if it had been entered in the current shell. at
even takes care to retain the current environment, in order to reproduce the same conditions when it executes the command. The time is indicated by following the usual conventions: 16:12
or 4:12pm
represents 4:12 pm. The date can be specified in several European and Western formats, including DD.MM.YY
(27.07.15
thus representing 27 July 2015), YYYY-MM-DD
(this same date being expressed as 2015-07-27
), MM/DD/[CC]YY
(ie., 12/25/15
or 12/25/2015
will be December 25, 2015), or simple MMDD[CC]YY
(so that 122515
or 12252015
will, likewise, represent December 25, 2015). Without it, the command will be executed as soon as the clock reaches the time indicated (the same day, or tomorrow if that time has already passed on the same day). You can also simply write “today” or “tomorrow”, which is self-explanatory.
$
at 09:00 27.07.15 <<END
>
echo "Don't forget to wish a Happy Birthday to Raphaël!" \
>
| mail lolando@debian.org
>
END
warning: commands will be executed using /bin/sh job 31 at Mon Jul 27 09:00:00 2015
at now + numero periodo
. periodo può essere minutes
, hours
, days
o weeks
. numero indica semplicemente il numero di dette unità che devono trascorrere prima dell'esecuzione del comando.
cron
, è sufficiente eseguire crontab -e
ed eliminare la riga corrispondente nel file crontab. Per le attività at
, è quasi altrettanto facile: eseguire atrm numero-attività
. Il numero dell'attività è indicato dal comando at
quando la si pianifica, ma è possibile ritrovarlo con il comando atq
, che mostra l'attuale elenco di operazioni pianificate.