How to set up cron task on Ubuntu

Step 1

Create shell script

Example (

git pull

Make it executable

$ sudo chmod +x

Step 2

Execute crontab -e and add command to cron configuration file. Command must have format “minute hour day-of-month month day-of-week command”.


00 17 * * *

Step 3

Restart cron

$ sudo service cron restart

Get cron logs

$ sudo grep cron /var/log/syslog

View cron messages

$ cat /var/mail/username