Skip to content

Instantly share code, notes, and snippets.

@Gimpy3887
Last active January 12, 2025 01:54
Show Gist options
  • Save Gimpy3887/58faf728808aae1a7d23c07fee40e4d0 to your computer and use it in GitHub Desktop.
Save Gimpy3887/58faf728808aae1a7d23c07fee40e4d0 to your computer and use it in GitHub Desktop.
Basics of crontab and things to remember.

Basic crontab Commands

crontab -e Edit crontab file, or create one if it doesn’t already exist.

crontab -l crontab list of cronjobs , display crontab file contents.

crontab -r Remove your crontab file.

Understanding Crontab Timing

I found this visual from a website.

image

Quirks to Keep in Mind

Pathing

Crontab only works with absolute paths--this means that the paths have to be explicit not relative. So, a way to get around this is to cd into the relevant directory i.e.

0 0 * * * cd /home/path/ && /home/path/script.sh

And to include paths that have spaces in them is by putting them inside quotations: "path/Some Folder".

Running Python

Must explicitly give the path to the Python folder that contains the Python binary.

0 0 * * * /usr/bin/python "/home/My Project/script.py"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment