# systemd timers - timers replacement to cronjobs ## how to set up - create a script you want to run nvim ~/dailyscript.sh ``` #!/usr/bin/env bash printf "Daily Script ran at $(date)" exit 0 ``` - make it executable `chmod +x ~/dailyscript.sh` - Create systemd service unit file `nvim /etc/systemd/system/dailyexecutethis.service` in case of rootless user specific service: `nvim ~/.config/systemd/user/dailyexecutethis.service ``` [Unit] Description=runs this daily. [Service] Type=simple ExecStart=/home/user/dailyscript.sh [Install] WantedBy=default.target ``` give execute permission: `chmod 755 dailyscript.sh` - Create timer unit file `nvim /etc/systemd/system/dailycommand.timer` in case of rootless user specific service: `nvim ~/.config/systemd/user/dailycommand.timer ``` [Unit] Description=runs at daily [Timer] OnBootSec=5min OnCalendar=*:0/14 Unit=dailyexecutethis.service [Install] WantedBy=default.target ``` give execute permision: `chmod 755 dailycommand.timer` - reload daemon systemctl daemon-reload - start service systemctl start dailycommand.timer If you want to keep this around after a reboot: systemctl enable dailycommand.timer run even when you arent logged in: `loginctl enable-linger username`