Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 4 of 4

This is a discussion on Finding the Cron Jobs help? in the Shared & Semi-Dedicated forum
Hey all, new subscriber, very impressed so far over my previous host (ICDSoft). Gigadeal is incredible! Anyway, poking around my CPanel, I found Cron Jobs. ...

  1. #1
    JPC Member
    Join Date
    Jul 2004
    Location
    Columbia, MO
    Posts
    12

    Finding the Cron Jobs help?

    Hey all, new subscriber, very impressed so far over my previous host (ICDSoft). Gigadeal is incredible!

    Anyway, poking around my CPanel, I found Cron Jobs. This looks to be a mighty powerful tool for a tweak guy like me, but upon clicking upon the "Click here to find out more about Cron Jobs" item, I get redirected to a Red Hat site asking for customer login credentials.

    Any idea where I might find some decent docs then? I've asked Google a few times but I haven't yet found anything I'm wild about. Thanks,
    -Parker

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Sorry, I don't have a good reference, but here's the gist of how to use cron:

    Each of the "time" fields allows you to specify when the job will start. You should use numbers in these fields.

    Minutes -- how many minutes after the hour the job is to start, 0-59 are valid values

    Hours - the hour of the day you want the job to start, 0 (midnight) - 23 (11 PM) are valid.

    Day - the day of the month (1-31 are valid, but the actual values you can use depends on the lenght of the month-aa job set up to run on Feb 30, for example, would never run).

    Month - the month of the year to run the job 1 (Jan) - 12 (Dec).

    Weekday - the day of the week that the job will run, 0 (Sun) - 6 (Sat).

    Command--the path to the script you want to run. This would be something like /home/USERNAME/SCRIPTPATH/SCRIPTNAME, obviously replacing the capitalized sections with the proper values. I recommend keeping your cron scripts in a directory outside of your public_htm, such as in /home/USERNAME/bin. You can also use the syntax shown on the CPanel page to run URLs.

    Generally speaking you want to make cron scripts return no output (or, possibly, write to a log file). However, if your script does return output, it will be sent to the email address you specify.

    You can use wildcards in any of the time fields as well. Placing a * in one of those fileds means "every." For example, the default values in CPanel are 0 0 * * * * which means that the script will run at 0 minutes and 0 hours (12:00 midnight) on every day of every month, no matter what weekday., Changing it to 0 0 * * * 0 would change that to run every Sunday at midnight, changing it to 0 0 1 * * 0 would run the script on the first of the month if and only if it is a Sunday, etc.

    You can use commas to specify multiple values in each field. For example, using 1, 5 in the weekday field would run the script on Monday and Friday. Likewise 1-5 in the weekday field would run it on "business days," Monday through Friday.

    Finally, using fractions in the time fields allows you to specify things like every 2 hours, etc. For example an hour value of */2 would run the command every other hour (2 am, 4 am, 6 am , 8 am, ...).

    I hope this helps. Cron can be a very powerful tool, but like anything that powerful, it takes some getting used to. A good way to get used to it might be to write a script that sends you the time that the scipt started. Collect a few of these email messages and compare them to when you were expecting to receive them (they may be a few minutes off from when you specified, but they should be fairly close) to be sure you understand what you are doing before you run anything thats business critical.

    Also, consider running your cron scripts at off times. For example, if you wnat to create a summary report of the previous day's sales, consider running it at 2 am instead of midnight as there may be many scripts running at midnight already, using a lot of server resources.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    JPC Member
    Join Date
    Jul 2004
    Location
    Columbia, MO
    Posts
    12
    Wowzers! That's well above and beyond the response I was expecting!

    Many thanks for the primer, saved to my HD. Thanks,
    -Parker

  4. #4
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    You're welcme. Glad you found it helpful.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

Bookmarks

Posting Permissions

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