Calling PHP from a Cron job

There are a number of options available to call a PHP script page from a Cron job. The option to use depends very much on your web host and how they have their servers configured. Option 2 is the one that I have found to work for me.

Option 1:
lynx -dump http://www.domain.com/file.php > /dev/null

Option 2:
php -q /home/username/public_html/file.php >/dev/null

Option 3:
wget http://www.domain.com/file.php

Option 4:
get http://www.domain.com/backup.php > /dev/null

9 Responses to “Calling PHP from a Cron job”

  1. cyberico Says:

    please help me, where i have to put the line:

    php -q /home/public_html/markettari/wp-content/plugins/postie/get_mail.php >/dev/null

    ???

    in wich file? with wich software installed on server?
    im trying to set a cron job for get-mail.php wordpress.

    thnx

  2. Matthew Capewell Says:

    Where you put the command depends on your web host.

    If you have a free blog hosted by someone like WordPress.com (like this blog) then you probably can’t create Cron jobs.

    If you have full website hosting with a control panel such as CPanel or Plesk then there should be some sort of Cron manager that lets you setup a Cron job and allows you to pick what day/time to run it.

  3. mynameisbond Says:

    yo! i’ll come back…http://google.com.uk

  4. jethai Says:

    My host (jodohost.com) has an Apache based Server API. You can find out by creating a test.php file and typing in it.

    Mine works with curl:

    curl -s -o /dev/null http://www.domain.com/wp-content/plugins/postie/get_mail.php

  5. Tixier Says:

    http://greatamps.info/replica-watches/man-replica-watch.php

  6. Edubads Says:

    100$ per click

  7. Swati Says:

    Hi All,
    I have set my cronjob in crontab,

    45 12 * * * root wget http://localhost/test.php

    its working fine. But after executing this cronjob everytime an empty file is get created in /root
    Can anybody tell why this is happening?

    Thanks in advance.

  8. online typing jobs Says:

    home online typing jobs

    typing jobs at home

  9. nir Says:

    Swati, try this command instead:

    /usr/bin/wget -O - -q http://www.telenovela.com/cron.php

    the -O - says to write the file to stdout, the -q to shut up)

Leave a Reply