Results 1 to 2 of 2

Thread: How to run crontab jobs every a few hours or every day?

  1. #1
    Administrator Kavoir's Avatar
    Join Date
    Dec 2009
    Posts
    183

    How to run crontab jobs every a few hours or every day?

    To schedule crontab jobs of the currently logged in user, use command:

    Code:
    crontab -e
    To open a text editor to edit the crontab scheduled jobs. Insert a new line:

    Code:
    0 */2 * * * /usr/bin/php5 /path/to/your/script.php
    Which simply means execute the script.php as PHP every 2 hours every day.

    To schedule it to run every day once:

    Code:
    0 0 * * * /usr/bin/php5 /path/to/your/script.php
    Note that the PHP command line interface may not be located at /usr/bin/php5 on your server, use 'whereis php5' or 'whereis php' to look it up.

    You can also write to the other users' crontab jobs.

  2. #2
    Administrator Kavoir's Avatar
    Join Date
    Dec 2009
    Posts
    183
    In the blank crontab jobs file, you will see:

    Code:
    # m h  dom mon dow   command
    # is the comment sign.

    m = minute, 0 ~ 59
    h = hour, 0 ~ 23
    dom = day of month, 1 ~ 31
    mon = month, 1 ~ 12
    dow = day of week, 0 ~ 6 (0 = Sunday)

    You can use * in place of a numeric value to mean 'every'.
    You can use a comma delimited list of legal values, e.g. 0,4,6
    You can use a range representation such as 2 - 5 to indicate an inclusive range.
    You can use */n to indicate a schedule of every n units.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •