Skip to content

Instantly share code, notes, and snippets.

@vikbert
Last active April 6, 2018 13:10
Show Gist options
  • Select an option

  • Save vikbert/5daa0f01c80f41b75f78133cc62f9396 to your computer and use it in GitHub Desktop.

Select an option

Save vikbert/5daa0f01c80f41b75f78133cc62f9396 to your computer and use it in GitHub Desktop.
[contab] organize the crontab smartly #cron, #crontab

Cron Job

Commands

crontab -e
crontab -l

How to start editing cron jobs

env EDITOR=vim crontab -e or crontab -e

The Job will be configured like this:

* * * * *  command to execute
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
│ │ │ └──────── month (1 - 12)
│ │ └───────────── day of month (1 - 31)
│ └────────────────── hour (0 - 23)
└─────────────────────── min (0 - 59)

Example Job:

every day at 16:00
0 16 * * *  rsync -avzh ~/.cheat/ ~/Dropbox/workplace/cheat/

workday (mo, di. we. th. fr) at 1AM	
0 1 * * 1-5 /bin/execute/this/script.sh

every 10 minutes
*/10 * * * * /bin/execute/this/script.sh

every 10 min. Log output to file	
*/10 * * * * /bin/execute/this/script.sh >> /var/log/script_output.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment