Setting up cron jobs in Magento

Syntax of crontab (Field Description)

Your cron job looks as follows for user jobs:
 
1 2 3 4 5 /path/to/command arg1 arg2
 
OR
 
1 2 3 4 5 /root/backup.sh
 
Where,

  • 1: Minute (0-59)
  • 2: Hours (0-23)
  • 3: Day (0-31)
  • 4: Month (0-12 [12 == December])
  • 5: Day of the week(0-7 [7 or 0 == sunday])
  • /path/to/command – Script or command name to schedule

Easy to remember format:
* * * * * command to be executed
– – – – –
| | | | |
| | | | —– Day of week (0 – 7) (Sunday=0 or 7)
| | | ——- Month (1 – 12)
| | ——— Day of month (1 – 31)
| ———– Hour (0 – 23)
————- Minute (0 – 59)
Your cron job looks as follows for system jobs:
1 2 3 4 5 USERNAME /path/to/command arg1 arg2
OR
1 2 3 4 5 USERNAME /path/to/script.sh

Example: Install Backup Job Script

If you wished to have a script named /root/backup.sh run every day at 3am, your crontab entry would look like as follows. First, install your cronjob by running the following command:
# crontab -e
Append the following entry:
0 3 * * * /root/backup.sh
Save and close the file.

More Examples

To run /path/to/command five minutes after midnight, every day, enter:
5 0 * * * /path/to/command
Run /path/to/script.sh at 2:15pm on the first of every month, enter:
15 14 1 * * /path/to/script.sh
Run /scripts/phpscript.php at 10 pm on weekdays, enter:
0 22 * * 1-5 /scripts/phpscript.php
Run /root/scripts/perl/perlscript.pl at 23 minutes after midnight, 2am, 4am …, everyday, enter:
23 0-23/2 * * * /root/scripts/perl/perlscript.pl
Run /path/to/unixcommand at 5 after 4 every Sunday, enter:
5 4 * * sun /path/to/unixcommand

2 thoughts on “Setting up cron jobs in Magento

  1. I like the helpful infо you provide in your
    articles. I will bookmark your blog and check
    again this frequently. I am quite certain I’ll learn lots of
    new stuff right here! GooԀ luck fߋr the next!

  2. If some оne wishes to be updated with neweѕt teϲhnologies after thɑt he must
    bе pay a quick visit this sіte and be up to dɑte every day.

Leave a Reply

Your email address will not be published.