DEV Community

Cover image for What do you use Cron jobs for?

What do you use Cron jobs for?

Madza on October 06, 2020

Cron jobs can be very useful to automate repetitive tasks. Users that set up and maintain software environments use cron to schedule jobs (commands...
Collapse
 
thefluxapex profile image
Ian Pride

I use them for all kinds of things depending on the machine and its use, but one of one's I always use on every machine is for running updatedb for mlocate as root every so often. I work on many projects often and it's hard to keep track of everything. For example:
I might work on 4 or 5 Fortran projects within a couple days and on both of my Linux and Windows partitions and say I need my last modified module file and I don't remember which project I did last so I'll run my lastmodified program which is dependent on mlocate being updated and with a cron job I don't ever have to worry about it.

Collapse
 
vonheikemen profile image
Heiker

Technically I use anacron, but it's the same principle. I only use it to setup a little reminder that I need to update the system (the one I use for work, not a server).

Collapse
 
yoursunny profile image
Junxiao Shi

Linux crontab:

  • daily "I don't have COVID" email reports
  • weekly meeting agenda email, scraped from Google Docs

pm2 cron:

  • daily restart of a Node.js service

GitHub cron:

Collapse
 
louislow profile image
Louis Low
  • daily "I don't have COVID" email reports

Ah... I used to create a tool to monitor COVID-19 situations in my Terminal. Go check that out.

# YARN
$ yarn global add pandemic-covid19
# NPM
$ npm i -g pandemic-covid19

screenshot 1
screenshot 2

Collapse
 
xanderyzwich profile image
Corey McCarty

I have an ETL job that receives files from our multi-value database to sync with our MS SQL server. Crontab triggers the jobs every minute to check for files and if files exist then they get processes.

Collapse
 
corentinbettiol profile image
Corentin Bettiol

I recently used cron jobs for two main things: to retrieve the latest issues of our clients to display them on a custom interface, and to update the list of pages of a website in a solr backend (full text search application).

Collapse
 
arturssmirnovs profile image
Arturs Smirnovs

Sounds interesting.. What's that solr project is about? and how you use it?
Could you add something about it?
Sounds interesting as I have solr project as well..

Collapse
 
corentinbettiol profile image
Corentin Bettiol

We created a package that we use with django-haystack in order to index Django-based sites pages.

When our customers post new content on their sites they just have to wait a few hours before it is crawled and available in the search index.

Collapse
 
louislow profile image
Louis Low

I use cronjob for a timely backup session with Equilibrium. Clean up and sorting files that I saved everywhere in my workstation and laptop with Sweep. It helps to reorganize files automatically into specific directories.

Collapse
 
dengel29 profile image
Dan
  • Daily scraping for a hobby project (AWS Lambda).

  • a Github Workflow that checks twice daily for fave'd articles, pulls them into a JSON in the repo for my personal website, then rebuilds the site.

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

One of the more 'unconventional' cron jobs I have on one of my systems fires off an Ansible playbook that runs memory compaction and wipes free RAM in all the VM test environments on the system on a nightly basis. This originated back when the system had a very limited amount of RAM and I needed to ensure that none of the VMs used too much over a long period of time, but I've kept it around despite having more than enough RAM now because it actually improves behavior of KSM and THP on the host side, which in turn means the VMs run a bit faster on average.

One of the other interesting ones I have running on one of my systems is used to update the number of CPUs visible to BOINC based on the ambient air temperature in the room (measured using a USB connected thermometer) and the time of day so that the computer doesn't add too much to the thermal load of the HVAC system at times when it might be an issue.

Collapse
 
meisekimiu profile image
Natalie Martin

On my own personal Linux computer, I mainly use cron to schedule basic desktop experience things: my desktop background changes every 30 minutes and my window manager's color theme changes to a new one every morning. Besides that, I have a twitter bot I created hooked up to cron that tweets every 6 hours.

Most other system maintenance stuff, like trimming log files and such, are handled by services in systemd.

Collapse
 
michaelphipps profile image
Phippsy

Backups. Daily checks of bank numbers (Australian BSB). Doing regular checks for changes to the Australian Business Registry. Soon i will add insolvency notices to the daily checks as well.
I use daemons a lot more though.

Collapse
 
favyteam profile image
FavyTeam • Edited

Usually Cronjob script is need for doing same work every period that its needs. For example, getting some blockchain transaction every seconds. For practice purpose, Shared Server didn't support well for Cronjob. If you are trying to use cronjob script, You need to purchase VPS Server or Dedicated Server 😊

Collapse
 
_garybell profile image
Gary Bell

At Home:

  • Send disk space updates to my dashboard for NAS and External drive backups
  • rsync NAS to external hard drive

At work

A few things:

Currently live

  • Copying database backups from hosting provider to the office (allows more backups to be kept)
  • Copying website assets from hosting provider to the office

In development

  • Resizing of images to create thumbnails as a background task
  • Regenerate sitemap
  • email daily reports
  • Update tracking information

And likely a whole load of stuff I've not properly considered yet

Collapse
 
mohitmehta1996 profile image
mohitmehta1996
  1. Daily cron to delete server logs
  2. Every minute cron for Laravel
  3. Every 15 min cron to restart pm2 socket server
  4. Weekly cron to take backup and upload it to google drive
  5. Monthly cron to send me the system health summary via email
Collapse
 
ptasker profile image
Peter Tasker

I've got a cron running to update my Twitter username with the current weather. Runs every 20 mins.

Collapse
 
sinethn profile image
Sineth Neranjana

We use crontab for cleaning up yarn logs, general housekeeping stuff. Invoking batch processing programs which are not time critical

Collapse
 
ryands17 profile image
Ryan Dsouza

Mostly for backing up files, once in code as well where I needed to send notifications at a certain time to certain users.

Collapse
 
alaindet profile image
Alain D'Ettorre

To execute jobs on queue

Collapse
 
siddheshshankar profile image
Siddhesh Shankar

I have setup a cron job in jupyter notebook which periodically sends relevant news articles to various groups.

Collapse
 
flybot profile image
FlyBot

I used cron jobs to renew let's encrypt certificate, import currency rate and impott data from remote APIs

Collapse
 
yo profile image
Yoginth

I use Ubuntu's native crontab!

Collapse
 
nelsonmendezz_ profile image
Nelson Hernández

I use it in my github actions and show my post of the week medium

Collapse
 
peter279k profile image
peter279k

I use them for monitoring the service and server.

And I also use them to do data exchanging.