9
13 Comments

What is your use case for cron jobs?

Hey all 👋

I'm researching on cron jobs and the various use cases, while also looking for opportunities of improvement.

What is your use case for cron jobs? Examples:

  1. Send a daily report with new sign ups.
  2. Send a birthday email every year for each member.
  3. Daily backup
  4. ???

Thanks!

  1. 4

    Mostly using Kubernetes cronJobs:

    • scale application based on load (using multiple custom metrics)
    • check the availability of everything (internally + externally)
    • backup databases on our cloud provider
    • backup encrypted databases on a different cloud provider (as S3 object)
    • Various maintenance tasks
  2. 4

    Well I'm using self-hosted email software and they use cron jobs that run each minute to send scheduled emails / autoresponder emails.

  3. 2

    On my desktop I use them for taking snapshots of my file system every 15 minutes, hour, and day.

    For the product I work on for pay, we use them to every minute scan for new data + perform actions based on it. We had it as a daemon before but it would occasionally get into bad states due to unforeseen input so we turned in into a cronjob. If it gets into a bad state, it just dies, and gets rerun a minute later. Generally this is good enough as bad states are transient and minute latency is fine for us.

    1. 1

      The whole system every 15min? How long does it take?

      1. 1

        I use ZFS so it is instant.

  4. 2
    • For weekly or monthly subscription services, handle order cutoffs, weekly billing, etc.
    • Syncing data into third party integrations periodically, like email marketing systems
    • Running database cleanup or alert scripts
  5. 1

    I have a texting service that sends people that opt in daily (very silly) facts

    1. 1

      Haha good use case😀. Do you have a seperate computer/vps for this task? Or do you leverage some server you already use?

  6. 1

    I use cron jobs on different devices, for different purposes:

    • to send a newsletter (I prepare whenever and send it on following monday) [every week]
    • to monitor the status of the server and services [every 10min]
    • backup personal data to backblaze [every week]
    • dump databse of every website [every day]
    • backup server data to Amazon S3 [every day]
    • analyze server logs [every 30min]
    • cycle my VPN to change IP [every day]
    • rebuild 'static' dashboard with sensor data from my lab [every hour]
  7. 1

    I use a corn job to fire a off a function within a wordpress plugin that needs to happen every Tuesday at 2PM. Wordpress has a "cron job" which is more like a timer that will fire every hour or once every 24 hours.

    The reason why I don't use this is because once I have a client's site live I want to be able to activate the plugin at any time and just let the cron job know when it is Tuesday at 2 to fire the function.

  8. 0

    cron jobs are like a Swiss knife, very versatile but not particularly good at solving any specific problem.

    I use them exclusively in small projects that don't need to scale up and are not going to be updated often (if ever).

    In any other case I will use more scalable solutions like job queues, scheduled serverless functions etc.

    But since we are on Indie Hackers, probably many of us are working on smaller projects with simple architecture so I can see why they would be useful.

    1. 1

      It’s a scheduled serverless function just another Cron?

      I suppose crons are now another bad smell in most architectures

      1. 1

        Hey @goenning yes it is similar, but a serverless function unlike a cron is not tightly coupled to a single vm and that’s why it makes more sense in a complex architecture IMHO - I agree with you extensive use of cron jobs is an “ops smell” unless all your cron jobs are under version control and managed through your CI/CD pipeline

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 18 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments