A simple example of systemd timers. Inspired by this blog post.
1 - Go to /etc/systemd/system
2 - Create a FreeMemoryStatistics.service
unit file like so:
[Unit]
Description=Logs free memory statistics to the systemd journal
Wants=FreeMemoryStatistics.timer
[Service]
Type=oneshot
ExecStart=/usr/bin/free
[Install]
WantedBy=multi-user.target
3 - Create a FreeMemoryStatistics.timer
unit file like so:
[Unit]
Description=Logs free memory statistics to the systemd journal
Requires=FreeMemoryStatistics.service
[Timer]
Unit=FreeMemoryStatistics.service
OnCalendar=*-*-* *:*:00
[Install]
WantedBy=timers.target
4 - Start the service: sudo systemctl start FreeMemoryStatistics.service
5 - You should see the output of the free
command being executed every minut: journalctl -S today -f -u FreeMemoryStatistics.service