Skip to content

Instantly share code, notes, and snippets.

@petergi
Last active January 10, 2023 22:39
Show Gist options
  • Select an option

  • Save petergi/62f838d12b4cf4df455ae24815f1ed90 to your computer and use it in GitHub Desktop.

Select an option

Save petergi/62f838d12b4cf4df455ae24815f1ed90 to your computer and use it in GitHub Desktop.

set the shell

SHELL=/bin/bash

set a PATH

PATH=/usr/bin:/usr/sbin:/usr/local/bin

incorrect way of setting PATH

PATH=$PATH:/do/not/do/this

crontab format

* * * * *  command_to_execute
- - - - -
| | | | |
| | | | +- day of week (0 - 7) (where sunday is 0 and 7)
| | | +--- month (1 - 12)
| | +----- day (1 - 31)
| +------- hour (0 - 23)
+--------- minute (0 - 59)

the % sign has special meaning,

% signs must be escaped such as \%

compute your crontab periodicity format online

https://crontab.guru/

Examples

every 15 min

*/15 * * * * /home/user/command.sh

every midnight

0 0 * * * /home/user/command.sh

every Saturday at 8:05 AM

5 8 * * 6 /home/user/command.sh

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