For the lack of thinking this through (and dealing with Luks volumes all day) What would an efficient entry be to execute a command on the 1st Saturday of the month look like in a crontab file?
This is a bit over my head as I’m not a great scripter and I appear to be getting more advanced when using crons, so it seems.
Looks like this is going to work:
0 9 1-7 * * [ “$(date ‘+%a’)” = “Sat” ] && some_path/somescript.sh
Try to drop a script in /etc/cron.daily which looks like,
If (date of week == 6 && date of month < 7)
Brings back a few memories, been years since I used a cron job.
Is there a reason for not using systemctl?
Habit mainly. I have a bunch of maintenance scripts that I have used and developed over the past few years.
I’m always open for new and better ways of doing things.
I like what chroot mentioned but I’m unsure if I have the ability to actually pinpoint a time when I want things to start. As I understand it (at least at one point) using /etc/cron.daily runs things that day but not at specific times.
Forgot systemd rules now.
That’s actually interesting… Can timers actually be set to actually run on certain days at certain times?
Ah I see that! OnCalendar
Looks very doable and gives me a few more projects for the next few weekends.
Thank you both, chroot and sammiev.
Either way I go, I’m moving away from the mess (admittedly) I created.
YES!!! off loaded my user crons to systemd.
Can you show what you did?
I wouldn’t know the difference between a cron job and a blow job.
And I am ok with it.
It’s likely unlimited, here’s the one I did up a few years back.
It runs 10 min after boot and every 24 hours after that.
I need to run for a bit. I’ll document examples and pages that helped me out.
Ok, so I’ll include an example (for updating newsboat) and the 2 sites I used as referance.
Description=Newsboat update service
Description=newsboat update timer
I opted for the --user space to run this.
The jist of the timer, is that I have this set to run/update every 6 hours.
You enable/start it as you would any other service.
Check out the following links as it’s pretty much to the point.
The second link focuses on Oncalendar - this is key if you want cron-type functionality.
Thanks @altman !
I’m far from being an expert in this feature but this worked for me. Now I just need to figure out how to send the completed task, an email
Ah ha! Caveat with using systemd, there isn’t a mailto feature. That’s Ok, I can add this to the script I’m calling:
ExecStart=/bin/bash -lc "echo \"$(whoami) created this message on $(date) to remind you about...\" | mutt -s \"Don't forget...\" firstname.lastname@example.org"
Well, it needs to be modded a bit but I did run a modded version on the cli and it works perfectly!!
So ideally, it would be ran after a scheduled task completes and of course, I would need to pipe the output of the task (for example, running a backup that captures backed up file) and attach that to the email.
lol. - this gets complex.
I’m changing the topic to something like, using systemd instead of crontab.