As developers, we are lucky to be able to use our own skills and knowledge to improve our life.
And I recently dug into about cron jobs and how impactful and time saving they can be in our daily life.
🧐 I'm curious on which ones you used daily (in a personal or professional way it does not matter!)
💪 Share us your best ones to give us some ideas to build around.
Any public repo are welcome!
🤩 I would love to find somewhere a curated list of best cron jobs ideas to setup during spare time! (might start a collaborative repo on this topic?)
Personally, I'm starting by setting up a cron job to backup every day my computer files into my NAS.
Do you have any favorite cron jobs that you are frequently using?
Top comments (18)
A good one is to send to yourself a reminder to stop working at a given hour
I have a randomized one to tell me to eat less sugar. Sometimes I get the email as I'm arriving at the supermarket :)
Nice one ahah.
I have one that runs a node script on a Pi just after midnight every night to (1) obtain the sunrise and sunset times for the day, and (2) set a schedule for my Philips Hue lights based on those values!
'docker system prune -f' every 5 minutes
For me, I have one that restarts a node instance. We have to use Oracle and the drivers have a memory leak. This in turn means, on our Dev and UAT machines, they start to hang within 2 hours. It used to be I manually restarted them.
I now just have a cron job that restarts the servers regardless on the hour, every hour. That in itself opens other issues but at least I don't need to be present 24/7.
Oh, and if you're wondering, Oracle Support is terrible.
Ah, interesting question. I'm enjoying the other responses. I want to share 3 of my cron-related projects.
scrape_pages_with_curl.sh I'm interested in scraping data from certain news and property sites to understand the water crisis in my city. I've done that for over a year.
twitterverse I download Twitter API data daily using a tool I wrote. I run it to fetch trend data from countries and cities. And also to get tweets for a couple of search queries of interest to me and friends.
uni-cron Unfortunately, crontab alone can't run them reliably on a laptop which is not always on and online. And running all jobs hourly (when they only need to run once a day) is overkill for resources, but that's what I've been today. But, as of yesterday, I have a tool what integrates with crontab that will run your tasks exactly once a day and will keep retrying them throughout the day if they fail. Keen to hear thoughts on this! Or to find if there is a solution for Mac out there already.
I got one to open and close my blinds (RPI); once in the morning and once at night.
I have one that scrapes lottery numbers off a website and emails them to me because I'm to lazy to open a web browser and go look at them.
And did you win since then? 😁
Alas no, I still have to go to work tomorrow.
I wrote myself a telegram bot that scrapes the website of my favorite football team to get the matches schedule, then it sends them to me as a message then adds them to google calendar
Excellent! 🤟 I made exactly the same for my amateur handball club to scrape their results!
I use a daily cronjob to pull all my bookmarks from pinboard and export them to CSV. That way I have a backup of my data and I can grep through it together with other notes.
gist.github.com/neudabei/ba78dd562...
My cron jobs mail me stuff: