Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

Setting up a cron job to invoke a PHP script

Quote Reply
Setting up a cron job to invoke a PHP script
Hi All,

I write a php script that work with Links SQL. I want setup a cron job to invoke this script. Please let me know how do I edit in the cron.txt. I use Linux/Unix system.

Thanks,

Beck
Quote Reply
Re: [Beck] Setting up a cron job to invoke a PHP script In reply to
It all depends on how you want to invoke the script. If you want to use something like;

lynx http://www.site.com/folder/script.php

...then you would just put something like this in your cron file;

Code:
x x x x x x lynx http://www.site.com/folder/script.php

(make sure there is a new line at the end of the file, or cron WILL NOT work, as I found out the hard way)

If you want to try and run it manually, you could try invoking it via /usr/bin/php (not all systems have it installed here). Again, a sample of its use;

/usr/bin/php /full/path/to/php/script.php

...then you would just put something like this in your cron file;

Code:
x x x x x x /usr/bin/php /full/path/to/php/script.php

...or possibly;

Code:
x x x x x x php /full/path/to/php/script.php


Then, in SSH, you need to 'cd' to the directory where you uploaded the cron.txt file. Do this with;

cd /path/to/folder <enter>

Then you need to type;

crontab < cron.txt

This will import the new cron file, and by doing a `crontab -l` you should be able to see the cron entry in there.

This is only a rough guide I quickly wrote up... so don't take me up on it if it doesn't work to perfection Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!