Cronjobs

Photo by Djim Loic on Unsplash

Cronjobs

running stuff in the background at a specified time is awesome

I forget to backup my files and so i use cron to do it for me.

Here is a basic rundown-

  • crontab is the tab of all cronjobs
  • run crontab -e it will ask for setup, use your favorite editor
export EDITOR=nvim

now run crontab -e again and you should be able to access the file

# Add this line to your crontab file to run the backup every day at 2 AM
0 2 * * * rsync -ah --info=progress2 /path/to/source /path/to/destination

those asterics are wildcards! It means run it everytime

use this command format examples for cronjobs

mhdommondowcommand
minuteshoursdaymonthday of the weekcommand
304**64:30 every Saturday
1514***2:15 every day
00**012:00 AM every Sunday
308**1-58:30 AM every weekday
45310**3:45 AM on the 10th
59233112*11:59 PM on December 31st