Page 1 of 1

cronjob need help

Posted: Tue Sep 05, 2006 7:30 pm
by Think Pink
Hello, I know this is a common question, but I tried to search before ask a question, so pls don't mind.
I'm trying to create a cron job that will execute a php script.
The ideea is that I don't know where to put the script. I mean I know into wich directory I want but I don't know what would be the path for it.
So here is what I see in my FTP program
domain.com
[etc]
[mail]
[public_html]
+ my_dir_1
+ my_dir_2
+ cgi-bin
[public_ftp]
[tmp]

I would like to put my script cronjob_script.php into public_html/my_dir_1

I use CPanel 10, and when I click Cronjobs icon, I am redirected to a page where I have to choose from Standard and Advanced.
I choose Standard, and there is a Entry 1 filed where I am supposed to enter Command to run.
My question is what is that Command, considering where I want to put my script.
Thx in advance and sorry for repeating (maybe) the post

Posted: Tue Sep 05, 2006 8:47 pm
by wtf
Your script can reside anywhere on the server. When you create your cron job specify the script path.

for example

13,18,23,28 5 * * Mon-Fri /path/to/my/php/file.php

http://floppix.ccai.com/cron.html

Posted: Tue Sep 05, 2006 9:32 pm
by Think Pink
thank you.
I hope I understand.
so basically, i can do: /public_html/my_dir_1/my_cron_script.php
Correct me please if i'm worng.

Posted: Tue Sep 05, 2006 9:49 pm
by wtf
That's correct. However, you'll probably have to specify entire path to the file. If you don't know the path you can do this.

Create a dummy.php

Code: Select all

<?php
echo __FILE__;
?>
and put it in the same directory where you want my_cron_script.php to reside.

Access dummy.php from web browser. You should get something like

Code: Select all

/usr/someusername/whatever/blah/public_html/my_dir_1/dummy.php
Grab the path from there and set it up in in the cron

Posted: Wed Sep 06, 2006 7:57 pm
by pedrotuga
usualy something like
/home/username/public_html

but.. run the script wtf told you