{"id":3188,"date":"2017-06-27T09:51:34","date_gmt":"2017-06-27T09:51:34","guid":{"rendered":"http:\/\/wiki.davelevy.info\/?p=3188"},"modified":"2025-12-28T15:15:41","modified_gmt":"2025-12-28T15:15:41","slug":"systemd-ptui","status":"publish","type":"post","link":"https:\/\/davelevy.info\/wiki\/systemd-ptui\/","title":{"rendered":"Systemd (ptui)"},"content":{"rendered":"\n<p>Originally written in 2017. I said, &#8220;It seems systemd can&#8217;t be avoided. I am annoyed at having to relearn stuff for a problem not worth solving&#8221;. I had another look in 2025, added some links as this time I wanted to move some job commands from cron to systemd i.e. <span style=\"text-decoration: underline;\">run the programs\/scripts periodically<\/span>. Here are my notes as I learn to use it.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Originally, I made two service definition files, and <a href=\"https:\/\/github.com\/dfl1955\/ubuntu-tools\/tree\/master\/services\">posted them to this git folder<\/a>, for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Deluge_(software)\">deluge<\/a>, and no2ip&#8217;s DNS Update Client. These are both daemons. In my github folder, there is also a script for enabling sysstat which references timers. I had to write <a href=\"https:\/\/github.com\/dfl1955\/ubuntu-tools\/blob\/master\/services\/noip2.service\">a service file for no-ip&#8217;s dynamic update client<\/a>. I remain confused about the choice of the type argument, but <a href=\"https:\/\/superuser.com\/questions\/1274901\/systemd-forking-vs-simple\/1274913\">the link from red hat below<\/a> is very clear &amp; helpful. <\/p>\n\n\n\n<p>So in looking to define services that ran periodically and ended, research and the links below, pointed me at .timer files. There are now separate scheduler files, which maybe an answer to the crontab permission problems I am having.<\/p>\n\n\n\n<p>In the end, I cheated, I asked google gemini to write for me,<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/gemini.google.com\/app\/f162afcfbd83d406\">Systemd service for daemon script<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/gemini.google.com\/app\/3ed67761bf369414\">Systemd service for scheduled script<\/a><\/li>\n<\/ol>\n\n\n\n<p>You&#8217;ve got to laugh. As I worked though some of the documents below, I discovered that Raspbian now distributed a service definition for apt and updatedb, which is\/was the problem I was looking to solve. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Links, found in 2025<\/h3>\n\n\n\n<p>I had another look in 2025, and in this case I was looking to run a script, not a daemon. I found these:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>On Systemd\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/documentation.suse.com\/smart\/systems-management\/html\/systemd-setting-up-service\/index.html\">Setting Up a systemd Service<\/a> from SUSE, comprehensive, includes how to make a service file and where to put it. It also categorises the service file types, such as .service &amp; .timer. <\/li>\n\n\n\n<li><a href=\"https:\/\/tecadmin.net\/run-shell-script-as-systemd-service\/\">How to Run Shell Script as Systemd in Linux<\/a> from techadmin.net, illustrates the creation and installation of a null daemon, including the use of the systemctl commands.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.service.html\">The Free BSD man page<\/a>, from freedesktop.org, the man page, comprehensive and dense and  their <a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/latest\/systemd.syntax.html from freedesktop.org\">syntax documentation<\/a>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Systemd Type argument\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.redhat.com\/en\/blog\/systemd-oneshot-service\">What sysadmins need to know about systemd&#8217;s oneshot service type <\/a> from Red Hat. It says, The <strong>oneshot<\/strong> service type is useful if you want to trigger a workflow &#8230; If you were to use a <strong>simple<\/strong> service type, you would end up with a dead service status after the script runs and exits, which is misleading for anyone who doesn&#8217;t have knowledge of that particular service. So probably not, it looks like for this use case I need Type=simple, which is the default.<\/li>\n\n\n\n<li><a href=\"https:\/\/superuser.com\/questions\/1274901\/systemd--vs-simple\/1274913\">https:\/\/superuser.com\/questions\/1274901\/systemd&#8211;vs-simple\/1274913<\/a> from Red Hat, another article primarily about Type=<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Systemctl\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-use-systemctl-to-manage-systemd-services-and-units\">A tutorial on the commands<\/a> from digital ocean, concentrates on the systemctl commands and parameters. It documents the is-active and is-failed arguments, which might be good to incorporate into my <a href=\"https:\/\/github.com\/dfl1955\/ubuntu-tools\/blob\/master\/tools\/check_service\">check_service<\/a> script. <\/li>\n\n\n\n<li>I <a href=\"https:\/\/www.devdungeon.com\/content\/creating-systemd-service-files\">found this at devdungeon.com<\/a>; it has another example service file, with a dummy daemon, and a good summary of the necessary systemctl commands. <\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Timer files\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/41560827\/how-do-i-use-systemd-to-replace-cron-jobs-meant-to-run-every-five-minutes\">How-do-i-use-systemd-to-replace-cron-jobs-meant-to-run-every-five-minutes<\/a> from stackoverflow, examples of .service and .timer files and discussion about enabling the ,timer service. It&#8217;s not very helpful in writing the frequency argument. <\/li>\n\n\n\n<li><a href=\"https:\/\/linuxconfig.org\/how-to-schedule-tasks-with-systemd-timers-in-linux\">How-to-schedule-tasks-with-systemd-timers-in-linux<\/a> from Linux config.org, a detailed description on writing a .timer file. It includes a lsit of syntaxes for defining times such as daily or using a cron like syntax. It also documents the &#8216;list-timers&#8217; argument for systemctl.<\/li>\n\n\n\n<li><a href=\"https:\/\/iamyaash.github.io\/spells\/posts\/linux\/systemd\/task-schedule\/\">Linux: Task Scheduling with systemd Timers<\/a>, by Yashwanth Rathakrishnan, a simple and short article, compares with cron, and states that one only needs to &#8216;start&#8217; the timer. Presumably the common basename of the files ensures that it all works well. <\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">2017 and an example from me<\/h3>\n\n\n\n<p>Some links from my original research &#8230;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/unix.stackexchange.com\/questions\/200280\/systemd-kills-service-immediately-after-start\">About starting and stopping<\/a>, from stack_exchange, and the importance of type=, it has a good write up of this, and I must have found it very useful. It is dated 2016<\/li>\n\n\n\n<li><a href=\"https:\/\/superuser.com\/questions\/1274901\/systemd-forking-vs-simple\/1274913\">Type= simple or forking<\/a>, from Red Hat, at superuser.com, and oneshot, made in 2018, another very comprehensive writeup of the Type argument. <\/li>\n<\/ol>\n\n\n\n<p>An example,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Unit]<br>Description=A description of the service<br>After=network.target <br><br>[Service]<br>Type=simple # check link No 1 &amp; 2 above<br>User=root<br>ExecStart=${program_path}\/${program_name} <br>#       explicit absolute path reqd<br><br>[Install]<br>WantedBy=multi-user.target<br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Originally written in 2017. I said, &#8220;It seems systemd can&#8217;t be avoided. I am annoyed at having to relearn stuff for a problem not worth solving&#8221;. I had another look in 2025, added some links as this time I wanted to move some job commands from cron to systemd i.e. run the programs\/scripts periodically. Here&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3189,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[8,3],"tags":[916,1056,911],"class_list":["post-3188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-technology","tag-linux","tag-systemd","tag-technology"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"https:\/\/davelevy.info\/wiki\/wp-content\/uploads\/2017\/06\/startup-w650.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/comments?post=3188"}],"version-history":[{"count":6,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3188\/revisions"}],"predecessor-version":[{"id":13673,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/3188\/revisions\/13673"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media\/3189"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media?parent=3188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/categories?post=3188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/tags?post=3188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}