Page 1 of 1
Cron job
Posted: Sun Jun 21, 2009 6:44 am
by gum1982
hi ive used putty and got the location for my cron job /usr/bin/php from my hosts streamline.net.
in my root folder of htdocs do i just add a php file called cron.php with the /usr/bin/php script at the begining.
example.
30 23 * * * /usr/bin/php
the number at the start are the time intervals right im confused with wheather using a text file basically and where to put the script.
if the cron.php had a simple mail function to send an email is this how it works what am i doing wrong any help pls.
im trying to follow this tutorial.
http://www.webmasters-central.com/artic ... b-is-easy/.
Re: Cron job
Posted: Mon Jun 22, 2009 7:55 am
by patrickmvi
What is the name of the script you're trying to execute (including full server path)? Also, in most cases, you will need to run a command via SSH to activate the cron such as "crontab" or something like that. You may be able to do it dynamically via PHP but that would depend on your hosting provider. Do you have SSH access to your server or perhaps access to some sort of control panel like PLESK or CPanel? Normally those allow you to create cron jobs (some of these things call them scheduled tasks or jobs). This may have alleviate the troubles you are having.
Re: Cron job
Posted: Mon Jun 22, 2009 8:43 am
by gum1982
Hi thanks for the reply.
yes i have ssh access to the server through a program called puTTy i put in my ssh address and domain and i get logded in to use the command lines.
This is where i get confused as ive email my hosting and they say they do not provide support for cronjobs but you can use them.
this is the response they gave. "Unfortunately we cannot provide support for running cron jobs, this feature is completely unsupported as detailed in our support article located at:"
this is where i get confused on where to start to do it manually without PLESK or CPANEL.
Re: Cron job
Posted: Mon Jun 22, 2009 1:33 pm
by patrickmvi
What is the full server path to the script you are trying to set up in the cron job? Also, does it contain any code that uses relative paths from the scripts location (ex: include/require/fopen)? If so, you may need to "chdir" to the correct folder within your script first before you try to do anything else.
Re: Cron job
Posted: Mon Jun 22, 2009 1:48 pm
by gum1982
hi thanks for the reply
the full server path to my script is /home/fhlinux136/s/samuelrweast.co.uk/cron.php
can you please explain "chdir"
is this where i run these commands
crontab filename Install filename as your crontab file
crontab -e Edit your crontab file, or create one if it doesn’t already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file.
Re: Cron job
Posted: Mon Jun 22, 2009 2:06 pm
by gum1982
Thought an image might help
dont no where to go from here or how too setup an empty one

Re: Cron job
Posted: Tue Jun 23, 2009 3:04 pm
by patrickmvi
Let's say you wanted to run your script every 5 minutes you would enter the following after you type "crontab -e":
*/5 * * * * /usr/bin/php /home/fhlinux136/s/samuelrweast.co.uk/cron.php
Then you would save it. Personally I like editing a text file and putting in what I want then just running:
crontab [MY TEXT FILE]
It does the same thing.
What I meant about chdir is that you should call it at the top of your cron.php script to put yourself in the right folder. If you'd want your script to run from the /home/fhlinux136/s/samuelrweast.co.uk/, you would call chdir as follows:
chdir("/home/fhlinux136/s/samuelrweast.co.uk/");
You can go here for more info on chdir:
http://www.php.net/chdir
Hope that helps.
Re: Cron job
Posted: Tue Jun 23, 2009 3:13 pm
by gum1982
brillant this looks like what ive needed to know thanks.
ill try it out and let you know.