Might be helpful to check out manpage on php:
http://www.linuxcommand.org/man_pages/php1.html
php [options] -f file [args]
Which is nice to know if you want to pass in arguments to your script from cron.

so your cron might look like this:
/5 * php -f /path/on/file/system/to/file.php

That would run the script every 5 minutes, adjust yours as necessary. Sometimes you need to specify the complete path to php too, eg /usr/local/php, or wherever it is on the server

Common pitfalls:
1. script not executible (use chmod to set permissions 700 or 744, I have no idea what you'd do on a windows server)
2. wrong path to script
3. include path is messed up when script is run via cron
4. problem w/ the hosting company (it happens, like they kill crond but don't restart it for whatever reason)

    thanks for your help mr.Jazz

    I succes to make the cron job but the problem now in the file path : I put it as :

    php-f/public_html/Pages/admin/file.php

    and recieve mail : /bin/sh: php-f/public_html/Pages/admin/file.php: No such file or directory

    how can I determine my file path

    thanks alot

      Please notice that white space is important in this line:

      php -f /path/to/your/php/script.php

      There is a space between php and -f and space between -f and path to the php file.

      Since many hosts have different set ups (some worse than others) you might have to experiment to figure out the file path. You could try a php script to help you...place it in same directory as the file.php script, and have it print $_SERVER['PATH_TRANSLATED'] to the screen. That should help you figure out file system path to your scripts.

      //dump.php
      print $_SERVER['PATH_TRANSLATED'];
      

      prints to screen the file system path to dump.php:

      /home/tom/public_html/freelance/battery/dump.php

        Write a Reply...