{"id":325,"date":"2015-06-06T14:13:02","date_gmt":"2015-06-06T06:13:02","guid":{"rendered":"http:\/\/play.datalude.com\/blog\/?p=325"},"modified":"2015-06-06T14:13:02","modified_gmt":"2015-06-06T06:13:02","slug":"how-to-change-the-time-anacron-runs","status":"publish","type":"post","link":"https:\/\/play.datalude.com\/blog\/2015\/06\/how-to-change-the-time-anacron-runs\/","title":{"rendered":"How to change the time anacron runs."},"content":{"rendered":"<p>Well this one took me a while to figure out, so I thought I'd blog about it in case I could save someone else some time. Anacron is installed on desktop \/ laptop orientated distributions as they're often switched off. It basically makes sure the daily, weekly and monthly cron jobs are run by checking the time they were last run, and running them if they weren't run in the last day, 7 days or 30 days respectively. It will also check these when the machine is rebooted. So it makes sense on machines that are rebooted frequently.<\/p>\n<p>However I have a server where it is also installed, alongside cron, and I wanted to change the time logwatch ran every day. My first attempt was to simply change the times in \/etc\/crontab, which contained lines like this<br \/>\n25 00\u00a0\u00a0 \u00a0* * *\u00a0\u00a0 \u00a0root\u00a0\u00a0 \u00a0test -x \/usr\/sbin\/anacron || ( cd \/ &amp;&amp; run-parts &#8211;report \/etc\/cron.daily )<br \/>\nChanging the time was ineffective, although I gather that if I'd removed anacron (or specifically the file \/usr\/sbin\/anacron ) then this approach would have worked.<\/p>\n<p>My research let me next to the \/var\/spool\/anacron directory where there are three timestamp files cron.daily, cron.weekly and cron.monthly. I experimented with changing the time on these to fool anacron into running earlier in the day. This was also ineffective.<\/p>\n<p>Hmm. Finally I found the solution, which kinda makes sense, but is well hidden. In \/etc\/cron.d\/ there is a file which runs anacron containing the line<br \/>\n30 23\u00a0\u00a0\u00a0 * * *\u00a0\u00a0 root\u00a0\u00a0 \u00a0test -x \/etc\/init.d\/anacron &amp;&amp; \/usr\/sbin\/invoke-rc.d anacron start &gt;\/dev\/nul<\/p>\n<p>Changing the time on this will make anacron run at your chosen time, and you'll have your logwatch report before breakfast.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well this one took me a while to figure out, so I thought I'd blog about it in case I could save someone else some time. Anacron is installed on desktop \/ laptop orientated distributions as they're often switched off. It basically makes sure the daily, weekly and monthly cron jobs are run by checking &#8230; <a title=\"How to change the time anacron runs.\" class=\"read-more\" href=\"https:\/\/play.datalude.com\/blog\/2015\/06\/how-to-change-the-time-anacron-runs\/\" aria-label=\"Read more about How to change the time anacron runs.\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,4],"tags":[],"class_list":["post-325","post","type-post","status-publish","format-standard","hentry","category-it","category-linux"],"_links":{"self":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/comments?post=325"}],"version-history":[{"count":0,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/325\/revisions"}],"wp:attachment":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/media?parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/categories?post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/tags?post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}