1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

cron-job: how2

Discussion in 'Programming' started by david_sakh, Jan 26, 2005.

  1. #1
    I have heard of automated scripts that fire on a regular basis called cron-jobs. Is there any EASY way I can set up one to e-mail me an entry in a data file or the result of an SQL query?
    SEMrush
    It's not extremely important, but it would be useful to me if I can set it up in under an hour.
     
    david_sakh, Jan 26, 2005 IP
    SEMrush
  2. dchoe

    dchoe Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    do you have ssh/telnet access to your site? also, i think cpanel has an option for cronjobs if your provider has it enabled
     
    dchoe, Jan 26, 2005 IP
  3. david_sakh

    david_sakh Peon

    Messages:
    1,225
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    let me check and see if I have cpanel. :eek: I've been using an ftp client out of habit.

    SSL is not sufficient? I can do that, for sure.
     
    david_sakh, Jan 26, 2005 IP
  4. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    First see if you can type in the comands with out the quotes
    for list > "crontab -l"
    and for edit > "crontab -e"
    to see if they are permited
    Then write at php script that will do what you want.
    Test it by loading it on the server and calling it from a browser.
    Note: the final version can not contain any print or echo statments.

    When all of that is done the rest is easy but tricky.
     
    mushroom, Jan 27, 2005 IP
  5. david_sakh

    david_sakh Peon

    Messages:
    1,225
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #5
    huh - there's a webserver command line? How do I acess it?
     
    david_sakh, Jan 27, 2005 IP
  6. Trance-formation

    Trance-formation Peon

    Messages:
    598
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    A quick and dirty work around (if you use a PC with windows and don't have access to cron on your server) is to set up a scheduled task to open your browser and call your script (I had to do this to update owlcrofts amazon tool automatically by running the script from my PC in the middle of the night:)
     
    Trance-formation, Jan 27, 2005 IP
  7. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    With out comand line access you can not set up a cron job.
    Contact your Hosting provider to see if you have it or if they are willing to set a cron job for you.
    Note, I have never had any thing to do with a C- panel
     
    mushroom, Jan 27, 2005 IP
    david_sakh likes this.
  8. david_sakh

    david_sakh Peon

    Messages:
    1,225
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ooo, I like quick and dirty.

    I suppose I'll use this as a temporary solution until I can resolve whether I have access to server cmd.

    thanks everyone.
     
    david_sakh, Jan 27, 2005 IP
  9. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Login via ssh (telnet is insecure), search Google for a windows SSH client (if using windows).

    Type:
    
    crontab -e.
    
    Code (markup):
    It will (most likely) put you in the vi editor, so you can edit your crontab.

    Hit i or Insert, to add your scheduled script(s). One per line.

    The syntax is:

    
    Minute   Hour   Day of Month   Month   Day of Week   Command 
    
    Code (markup):
    Examples:

    Run every minute, hour, day, day of month, day of week:
    
    * * * * * /path/to/script
    
    Code (markup):
    Run every 30 minutes, during every hour, every day of month, every month, every day of week:
    
    */30 * * * * /path/to/script
    
    Code (markup):
    Run every Monday, and Tuesday:
    
    * * * * * 1,2 /path/to/script
    
    Code (markup):
    I could go on with examples, but you should probably try the Linux man pages if you need a in depth description.

    When you've completed your edits, hit [ESC] key, then type:
    
    :wq
    
    Code (markup):
     
    nullbit, Feb 20, 2005 IP
    david_sakh likes this.