SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 37

Thread: Cronjob

  1. #1
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, I couldn't find somthing about cron jobs here, so can anybody tell where to find a good tutorial about setting up cron-jobs.
    Actually I'm looking for a simple cron job running my php3 script once a hour and tried this here:
    0 * * * * lynx -dump http://mydomain.de/myfolder/myfile.php3
    but anyway it is doing nothing.
    Thanx you for helping, Alex

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:

    1 */1 * * * php /path/to/file/ /dev/null

    You cannot use the http://www.domain.com/path way, you must use the total path:

    /home/username/public_html/file.php

    The above is what I use, your is most likely different.

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot use the http://www.domain.com/path way, you must use the total path:
    Yes, since he uses lynx to fetch the page.
    Also
    0 0 * * * php /path/to/file/ /dev/null
    should be
    0 0 * * * php /path/to/file > /dev/null
    # redirect to /dev/null and not passing /dev/null as a param.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean it should look like this on unix ?

    0 0 * * * php /www/username/directory/file.php > /dev/null

    And what about the time ? Is "0 0 * * *" correct for once a hour?

  6. #6
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, 0 0 * * * runs at midnight every day.
    0 * * * * runs every hour at *:00

    yes, that should be the correct command.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  7. #7
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    1. Choose what minute of the hour:
    Easy one is 30
    2. Specify it to do it every hour of every day of every month, etc...

    * * * *

    3. So your final code is:

    Code:
    30 * * * * php /www/username/directory/file.php > /dev/null
    Good Luck!

    Peter

  8. #8
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks good, thank you

  9. #9
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still have a problem with this cron job. I always get the error message ( via e-mail on telnet ) that the permission was denied. I get this mail here :

    Message :
    php /www/username/myfolder/myfile.php
    3 > /dev/null
    X-Cron-Env: <SHELL=/bin/sh>
    X-Cron-Env: <HOME=/home/username>
    X-Cron-Env: <PATH=/usr/bin:/bin>
    X-Cron-Env: <LOGNAME=username>

    : Permission denied

    I don't know what to do, on "Wsftp" the settings for the folder look like this
    Owner ( Read -ok / Write -ok / Execute -ok)
    Group ( Read -ok/ write -ok / Execute -ok)
    Other ( Read -ok/ write -ok / Execute -ok)

    and I checked the file itself, it works without problems testing it on my browser.
    Thanx for help, Alex

  10. #10
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check that command under telnet, see if it works with that path
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  11. #11
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I get the same error, permission denied.

  12. #12
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So are you sure that it's the right path to the file own by you? Or you're trying to run other's file!
    To find the right path, go to the directory that has the file, type "pwd".
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  13. #13
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it is my own file on my directory on the unix-server.
    So the path looks like this :
    /home/myusername/www/myfolder/myfile.php
    and that is what I used for the cron-job but got the error message "permission denied" all the time.

  14. #14
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Up there, I saw the command you use in cron is:
    php /www/username/myfolder/myfile.php

    so basically the "/home" is not there.
    Double check. There is no reason why it denied running your file.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  15. #15
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It get the error message in both cases, doesn't matte if I type:
    /home/username/www/myfolder/myfile.php3
    or
    /username/www/myfolder/myfile.php3

    Is there any command for telnet to check if a folder is locked ore not ?

  16. #16
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "ls -a <dirname/filename>"
    To run a php script, only need read permission (unlike perl scripts)
    So it's something like this: rwx---r-- (704)
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  17. #17
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, what is this command for? I did it, and now I can not even enter the folder with "wsftp" anymore. I get the same error message now: "Permission denied" for the whole folder.
    I did it like you said, but without < and > as I got a syntax error with it. So I did this here:
    "ls -a /home/username/www/folder/file.php3" (without "") and got this answer:
    /home/username/www/folder/file.php3* (what does "*" mean)
    Thanx, alex

  18. #18
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, I just found some good tutorials that could help me to solve my problems. There is one for setting up crontabs at
    http://www.superscripts.com/tutorial/crontab.htm and another one for all this telnet staff at :
    http://www.superscripts.com/tutorial/telnet.html

    So I hope I can solve my problem now. Thank you all for helping, Alex

  19. #19
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Even though this is an extremely late reply, I know how to use PHP and crontabs but i want to know why am I using:

    /dev/null

    ??

    Thanks

  20. #20
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that's saying where to send the output.

    /dev/null is the null device which is the unix equivelent of the "recycling bin". So its just saying trash the output (rather than sending it to standard out - the shell screen).

  21. #21
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that's one of the many nice things about Unix system, all devices are considered as files, so you can redirect to your floppy disk, dev/null, whatever.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  22. #22
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://freshmeat.net/articles/view/237/
    They're trying to make every single thing a file in a Unix-like system. It's an interesting read.

  23. #23
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really interesting, I only read part of it but couldn't imagine you would do a cd into a file
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  24. #24
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, nice to see that you have resuscitated my thread as my problem still is unsolved. Let me tell you the situation again. I have a file (file.php3 / updating a non static html page / see Kevin's tutorial "semi-dynamic-pages"), and want to run it once a hour. Running the file in my browser works fine. My cronjob looks like this:
    15 * * * * php3 /home/username/www/folder/file.php3 > /dev/null
    I put it in a file called "cron.tab" and started the cronjob with telnet like this: crontab /home/username/www/folder/cron.tab
    and get this when I check it with "crontab -l" :

    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    # (/home/úsername/www/folder/cron.tab installed on Sat Apr 14 18:11:58 2001)
    # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
    15 * * * * php3 /home/username/www/folder/file.php3 > /dev/null

    I think this looks good and should work fine, but actually it is doing nothing, really nothing, I do not even get a error message. Any idea what I could do here?

  25. #25
    SitePoint Enthusiast nguip's Avatar
    Join Date
    Apr 2001
    Location
    Malaysia
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow..

    I haven't try the crontab yet.. so I cannt help

    Just want to learn more about this so I hope you could teach me how u do this if you had any success
    Ngu I.P.
    Web Developer


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
  •