{"id":273,"date":"2026-08-21T12:17:34","date_gmt":"2026-08-21T12:17:34","guid":{"rendered":"https:\/\/beneford.com\/Blog\/?p=273"},"modified":"2026-08-21T16:30:00","modified_gmt":"2026-08-21T16:30:00","slug":"from-cron-to-systemd-timers","status":"publish","type":"post","link":"https:\/\/beneford.com\/Blog\/index.php\/2026\/08\/21\/from-cron-to-systemd-timers\/","title":{"rendered":"From cron to systemd timers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You may have come across new Linux distributions don&#8217;t include cron. As they use systemd, they are encouraging you to use systemd&#8217;s timers instead.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">cron was simple to use<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">crontab -e and enter the commands you need.<br>Yes, there is the awkward syntax to say exactly when to run it, but, like me, you probably have something like this that you put at the top of your crontab:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mm hh dd MM dow\n#  |  |  |  |   \\--day of week (0=sun, etc.)\n#  |  |  |  \\------month (1-12 or jan\/feb etc.)\n#  |  |  \\---------date (1-31)\n#  |  \\------------hour (0-23)\n#  \\---------------minute (0-59) &#91;*\/5 = every 5 mins]\n  30 04  *  *  1 \/home\/user\/script <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">What follows is the systemd way of doing the same thing:<br> at 4:30am every Monday, run <code>\/home\/user\/script<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Systemd timers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Systemd timers aren&#8217;t hard to use, but the setup is different.<br>You create <strong><code>\/etc\/systemd\/system\/mytask.timer<\/code><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=this template runs every Monday at 4:30am\n\n&#91;Timer]\nOnCalendar=Mon 04:30\nUnit=mytask.service\n\n&#91;Install]\nWantedBy=timers.target<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> and you create <code><strong>\/etc\/systemd\/system\/mytask.service<\/strong><\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=this task does something\n\n&#91;Service]\nExecStart=\/home\/user\/script<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once created, check the syntax (and fix any errors)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemd-analyse verify \/etc\/systemd\/system\/mytask.*<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then you can start the timer<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable mytask.timer\nsystemctl start mytask.timer<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and you can check everything is working with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl list-timers<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may have come across new Linux distributions don&#8217;t include cron. As they use systemd, they are encouraging you to use systemd&#8217;s timers instead. cron was simple to use crontab -e and enter the commands you need.Yes, there is the awkward syntax to say exactly when to run it, but, like me, you probably have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":3,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions\/276"}],"wp:attachment":[{"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beneford.com\/Blog\/index.php\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}