cronjob need help

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

cronjob need help

Post 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
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post 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
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

Post 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.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post 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
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

usualy something like
/home/username/public_html

but.. run the script wtf told you
Post Reply