ericii — 2011-11-08T01:03:01-05:00 — #1
I am curious as to how one would go about executing a PHP script via cron job.
I have a script that will send me a simple email.
I would like a cron job to execute the script once an hour.
How could I go about doing this?
I am running on the Apache module.
rubble — 2011-11-08T03:10:57-05:00 — #2
I did mine through cpanel and its quite straight forward. From memory you need to add php to the front of the path to the code.
titan21 — 2011-11-08T07:19:50-05:00 — #3
You coudl use exec() and pass the cron command as an argument.
ericii — 2011-11-08T11:07:53-05:00 — #4
I'm attempting to do mine through cPanel as well.
Do I just give the file path where it says "command"?
ericii — 2011-11-08T11:37:10-05:00 — #5
I figured it out.
elizabethq — 2011-11-19T16:08:49-05:00 — #6
We use a lot of cron scripts too and since no one has posted an example on this thread, I thought I would for anyone looking for an example.
"/usr/bin/php" "/home/myserver/scripts/cron/queue-message.php" >& /dev/null
For schedule of script execution you need to understand how the five parameters work (minute, hour, day, month and weekday) and once you've
got a grasp of these, execution of scripts is pretty flexible for when you want to.
trailsix — 2011-11-21T23:16:36-05:00 — #7
Using cpanel you can call a shell script that isn't located in your public_html folder:
Or you can use curl to call a page on your site:
Or you can call php to run a file
/usr/local/bin/php -q /home/username/public_html/mysite/cron.php
All of these are valid cpanel cron jobs
gizda — 2012-01-18T04:51:35-05:00 — #8
My host’s cron (Server API: CGI/fastCGI) support absolute URL of the php like: (http://www.mysite/example.php )
But what I’ve got is a command:
php "/web/mysite/mysite.com/administrator/components/comex/helpers/cron.php" username="admin" passwd="adminpass" template_id="50"
Is there possible to execute this command with custom php?(or I’m not sure the host enable .sh if so, how can I put the php command in the shell script to get the cron the full URL path?)
Could somebody help me out how can I solve it?
Thanks in advance