#AskFedi: is there a script / way to automate the restart of dnsmasq every 24 hours… on a VPS that runs on Debian 12?

(Funny how this would have sounded like a foreign language to me a mere year ago) 😆

Update: THANK YOU for the cronjob recommendation. Now looking for a tutorial that’s easy to follow for a newbie like me 😅

I really appreciate all the advice, YOU’RE THE BEST 🏆

#MySoCalledSudoLife

@elena a simple cron job should do

@mensrea sorry to bother you, but does this sound legit?

0 10 * * 1-5 systemctl restart dnsmasq

(I want it to run on weekdays at 10am)

I LOVED the explanation you sent, cronjobs feel like magic! sooo cool

@elena looks right from here
@elena no, wait: 0 0 10 * * 1-5
@mensrea @elena could you please explain the double zero? single seems correct https://crontab.guru/#0_10_*_*_1-5
Crontab.guru - The cron schedule expression generator

An easy to use editor for crontab schedules.

@def @elena single can be. the expression can have 5, 6, or 7 elements: seconds, minutes, hours, day of month, Month, Day of week, and Year. I've found including seconds is more predictable, and when you have a lot of jobs running it's good to start them off the hour and minute. eg, 10:12 05

@mensrea @elena Absolutely agree with using hour and minute to distribute the runs of cron jobs if there is lots of them. For example same job running on multiple servers, one might want avoid to running them at the same time.

As for the crontab format, I guess you are not talking about the standard cron distribution as that has exactly five time and date fields (https://man7.org/linux/man-pages/man5/crontab.5.html). TIL there are other variants, like nnCron, that support more params. Thank you.

crontab(5) - Linux manual page