{"id":63178,"date":"2025-09-19T08:29:07","date_gmt":"2025-09-19T07:29:07","guid":{"rendered":"https:\/\/www.bleuanus.nl\/?p=63178"},"modified":"2025-09-19T08:33:25","modified_gmt":"2025-09-19T07:33:25","slug":"create-scheduled-reboot-via-systemd","status":"publish","type":"post","link":"https:\/\/www.bleuanus.nl\/index.php\/2025\/09\/19\/create-scheduled-reboot-via-systemd\/","title":{"rendered":"Create scheduled reboot via systemd"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">These are the steps to create a scheduled reboot via systemd on Ubuntu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Filenames and unit descriptions in the example are chosen arbitrarily and can be changed.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add a service unit that restarts the system. To do that, create a new file in\u00a0<code>\/etc\/systemd\/system\/sched-reboot.service<\/code>\u00a0and add the necessary configuration into it. The following service config will run a forced reboot through systemctl whenever started.<code> [Unit] Description=Scheduled Reboot [Service] Type=oneshot ExecStart=\/usr\/bin\/systemctl --force reboot<\/code><\/li>\n\n\n\n<li>Add a timer, that will start the reboot service on a schedule. Create a new file in\u00a0<code>\/etc\/systemd\/system\/sched-reboot.timer<\/code>. The following config for the timer will run the reboot service daily at 4AM<code> [Unit] Description=Reboot Scheduling [Timer] OnCalendar=*-*-* 4:00:00 [Install] WantedBy=multi-user.target<\/code><\/li>\n\n\n\n<li>(Optional) Run\u00a0<code>systemd-analyze verify \/etc\/systemd\/system\/sched-reboot.*<\/code>\u00a0to check for errors in the config files. If the return is empty, the files are in order.<\/li>\n\n\n\n<li>Enable and start the timer by running\u00a0<code>sudo systemctl enable sched-reboot.timer<\/code>\u00a0and\u00a0<code>sudo systemctl start sched-reboot.timer<\/code>.<\/li>\n\n\n\n<li>(Optional) Run\u00a0<code>systemctl list-timers<\/code>\u00a0to see all active timers as well as their next and last start information.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This is an older question, but it comes up as search result and does not contain any info about systemd, so I will add an example on how to do scheduled reboots with systemd. Filenames and unit descriptions in the example are chosen arbitrarily and can be changed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>create new file: \u00a0<code>\/etc\/systemd\/system\/sched-reboot.service<\/code>\u00a0<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li><code>[Unit] Description=Scheduled Reboot<\/code><\/li>\n\n\n\n<li><code>[Service] Type=oneshot ExecStart=\/usr\/bin\/systemctl --force reboot<\/code><\/li>\n\n\n\n<li><\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>\u00a0<code>\/etc\/systemd\/system\/sched-reboot.timer<\/code>. <\/li>\n\n\n\n<li><code>[Unit] Description=Reboot Scheduling<\/code><\/li>\n\n\n\n<li><code>[Timer] OnCalendar=*-*-* 4:00:00<\/code><\/li>\n\n\n\n<li><code>[Install] WantedBy=multi-user.target<\/code><\/li>\n\n\n\n<li>(<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>Enable and start the timer by running:<\/li>\n\n\n\n<li><code>sudo systemctl enable sched-reboot.timer<\/code><\/li>\n\n\n\n<li><code>sudo systemctl start sched-reboot.timer<\/code>.<\/li>\n\n\n\n<li>(Optional) Run\u00a0<code>systemctl list-timers<\/code>\u00a0to see all active timers as well as their next and last start information.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>These are the steps to create a scheduled reboot via systemd on Ubuntu. Filenames and unit descriptions in the example are chosen arbitrarily and can be changed. This is an older question, but it comes up as search result and does not contain any info about systemd, so I will add an example on how [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[9,13,12],"class_list":["post-63178","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-service","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/63178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/comments?post=63178"}],"version-history":[{"count":1,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/63178\/revisions"}],"predecessor-version":[{"id":63179,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/posts\/63178\/revisions\/63179"}],"wp:attachment":[{"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/media?parent=63178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/categories?post=63178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bleuanus.nl\/index.php\/wp-json\/wp\/v2\/tags?post=63178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}