Let's learn how to use cron and crontab without summoning a daemon from the 9th circle of Bash. ![]()
Photo by Chris Barbalis on Unsplash
If you're tired of running cheeky.sh manually and wish the system could do it for you without lifting a finger, this guide is for you.
Cron is a Linux background service (A.K.A. daemon) that runs tasks at scheduled times. It's perfect for repetitive tasks that you'd rather not think about like the totally-legit commits we are going to do.
Crontab (which stands for "cron table") is, in the other hand, your personal list of scheduled commands. It tells the cron what to run and when it should be run.
They're perfect for:
- Running backup scripts.
- Sending automated reports.
- Running Cheeky daily to maintain your GitHub streak.
Open the terminal and type:
crontab -e
(If it's your first time, it will ask which text editor to use. Pick your favorite or do yourself a favour and learn Vim.
)
Here's the structure of a Cron Job:
To run Cheeky twice a day, I added a new line like this:
0 10,19 * * * /home/saraleitexyz/cheeky_commit_bot/cheeky.sh
This literally means:
- 0 10, 19 🠪 At 10:00 and 19:00 (IF the computer is on).
- * * * 🠪 Every day, month and weekday
- Command 🠪 Path to the script so it knows what to run.
- Before relying on cron, run your scripts manually. You REALLY don't want a script with an error running in the background.
- You can easily check your crontab anytime with
crontab -l.
And that's it! You can sit back and relax, Cheeky should be working just fine! 𓆝 𓆟

