Bash Fare lavori a orari specifici ripetutamente usando systemd.timer


Esempio

systemd fornisce un'implementazione moderna di cron . Per eseguire periodicamente uno script è necessario un servizio e un file del timer. I file di servizio e timer devono essere collocati in / etc / systemd / {system, user}. Il file di servizio:

[Unit]
Description=my script or programm does the very best and this is the description

[Service]
# type is important!
Type=simple
# program|script to call. Always use absolute pathes 
# and redirect STDIN and STDERR as there is no terminal while being executed 
ExecStart=/absolute/path/to/someCommand >>/path/to/output 2>/path/to/STDERRoutput
#NO install section!!!! Is handled by the timer facitlities itself.
#[Install]
#WantedBy=multi-user.target

Quindi il file del timer:

[Unit]
Description=my very first systemd timer
[Timer]
# Syntax for date/time specifications is  Y-m-d H:M:S 
# a * means "each", and a comma separated list of items can be given too
# *-*-* *,15,30,45:00  says every year, every month, every day, each hour,
# at minute 15,30,45 and zero seconds

OnCalendar=*-*-* *:01:00  
# this one runs each hour at one minute zero second e.g. 13:01:00