You are here
Shaun Raven - Wed, 2021/08/25 - 14:10
Hi everyone,
2 quick questions....
1. How do you change the apt cron task so that it's weekly not daily
2. If I wanted to reboot turnkey once a week automatically, how would I enter that into cron?
Many thanks in advance,
Forum:
Depends where the cron job is currently
There are 2 ways a (root user) cron job can be configured, either via the "crontab" (which allows incremental and precise timing and exists in /etc/cron.d) or via one of the other relevant cron directories in /etc.
I won't cover the "crontab" method here as it's a bit convoluted and may not be relevant or necessary.
So assuming that your current daily cron job is called 'foo', then it should be found in '/etc/cron.daily'. To make it run weekly instead, then simply move it to the '/etc/cron.weekly' directory. I.e.:
As for rebooting the server weekly, I would argue that if you need to reboot weekly, then there is almost certainly something wrong that should be fixed "properly" (or at least worked around via an alternate method). Regardless, to answer your question; this should work:
First the script to reboot:
Not sure if I'm looking at the right place here
Thanks for that jeremy - very informative. I looked in /etc/cron.daily and found apt-compat - I'm not sure if that's actually what I'm looking for. What I want to run daily seems (to me at least) to be the following process...
CRON-APT RUN [/etc/cron-apt/config]:
Am I looking at the right thing?
Apologies that I didn't explicitly respond to your question...
Rereading your OP, it's clear that you were explicitly asking about changing the auto security upgrades, but I responded with a general/generic answer... Sorry about that.
So the auto updates are run leveraging the cron-apt tool. It is run by cron from the cron-apt job, found here: /etc/cron.d/cron-apt. By default it will include contents something like this:
As noted in the comment, the time is randomised. This is to avoid all TurnKey servers hitting the repositories at the same time. In reference to my previous post, this is in "crontab" format. As I noted previously, it's a bit convoluted and I'm still not wanting to go into it, but if you would like to understand the actual crontab line (i.e. the line that starts '37 8 [...]') then please have a look crontab.guru. FWIW my apt upgrades will install at 8.37am every day.
To change it from running daily, to weekly, you just need to choose which day of the week you would like it to run on and swap the last/third asterisk ('*'). Change it to either a weekday number (0-6 where Sunday is 0, Saturday is 6) or the 3 letter day "code" (first 3 letters of the day; e.g. mon, tue, wed, etc).
E.g. if I wanted to run my apt cron job on Mondays, I would change the last line of the /etc/cron.d/cron-apt file from what I posted above to:
(see https://crontab.guru/#37_8_*_*_1)
Or
(see https://crontab.guru/#37_8_*_*_mon)
You can also change the exact time that it runs if you wish, but it's probably
No worries :)
Thanks Jeremy - changed it, so hopefully it'll only run once a week now.
Cron.d?
Yep, that's the one!
Yep that's the one. You can use cron.guru to work out the first part and if it doesn't work there's a "troubleshooting cronjob" page on our wiki that might come in handy.
cron
Hi Jeremy
Thanks for good cron manual
Add new comment