44
Systemd timers or classic cron?
(infosec.pub)
A community for everything relating to the GNU/Linux operating system (except the memes!)
Also, check out:
Original icon base courtesy of lewing@isc.tamu.edu and The GIMP
My number one reason for using systemd timers is just that I find it more readable than cron. Usually I want to run things
daily,weeklyormonthlyand systemd timers make that very easy.Here is an example:
backup.timer
backup.service
Another great feature is that the output of the script is logged to journald which is very convenient when you are troubleshooting why your backup failed last night.
While
crontabalso has keywords for@daily,@weeklyand@monthly, the automatic logging ofsystemdis useful and your example shows that it additionally allows to specify delays. I don't know howanacronhandles the latter.You can also easily see when the job last ran, if it was successful and when it will next run. As well as just trigger the service if you want it to run now.